mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-23 12:11:02 +02:00
Fix qdrant write
This commit is contained in:
parent
12bf05a2a6
commit
4bd251201e
1 changed files with 19 additions and 2 deletions
|
|
@ -12,10 +12,25 @@ import logging
|
||||||
from .... base import GraphEmbeddingsStoreService, CollectionConfigHandler
|
from .... base import GraphEmbeddingsStoreService, CollectionConfigHandler
|
||||||
from .... base import AsyncProcessor, Consumer, Producer
|
from .... base import AsyncProcessor, Consumer, Producer
|
||||||
from .... base import ConsumerMetrics, ProducerMetrics
|
from .... base import ConsumerMetrics, ProducerMetrics
|
||||||
|
from .... schema import IRI, LITERAL
|
||||||
|
|
||||||
# Module logger
|
# Module logger
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def get_term_value(term):
|
||||||
|
"""Extract the string value from a Term"""
|
||||||
|
if term is None:
|
||||||
|
return None
|
||||||
|
if term.type == IRI:
|
||||||
|
return term.iri
|
||||||
|
elif term.type == LITERAL:
|
||||||
|
return term.value
|
||||||
|
else:
|
||||||
|
# For blank nodes or other types, use id or value
|
||||||
|
return term.id or term.value
|
||||||
|
|
||||||
|
|
||||||
default_ident = "ge-write"
|
default_ident = "ge-write"
|
||||||
|
|
||||||
default_store_uri = 'http://localhost:6333'
|
default_store_uri = 'http://localhost:6333'
|
||||||
|
|
@ -51,8 +66,10 @@ class Processor(CollectionConfigHandler, GraphEmbeddingsStoreService):
|
||||||
return
|
return
|
||||||
|
|
||||||
for entity in message.entities:
|
for entity in message.entities:
|
||||||
|
entity_value = get_term_value(entity.entity)
|
||||||
|
|
||||||
if entity.entity.value == "" or entity.entity.value is None: return
|
if entity_value == "" or entity_value is None:
|
||||||
|
continue
|
||||||
|
|
||||||
for vec in entity.vectors:
|
for vec in entity.vectors:
|
||||||
|
|
||||||
|
|
@ -80,7 +97,7 @@ class Processor(CollectionConfigHandler, GraphEmbeddingsStoreService):
|
||||||
id=str(uuid.uuid4()),
|
id=str(uuid.uuid4()),
|
||||||
vector=vec,
|
vector=vec,
|
||||||
payload={
|
payload={
|
||||||
"entity": entity.entity.value,
|
"entity": entity_value,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue