mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-22 03:31:02 +02:00
* Bring QDrant up-to-date * Tables for data from queue outputs - Pass single Pulsar client to everything in gateway & librarian - Pulsar listener-name support in gateway - PDF and text load working in librarian * Complete Cassandra schema * Add librarian support to templates
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
|
|
from .. schema import GraphEmbeddingsRequest, GraphEmbeddingsResponse
|
|
from .. schema import graph_embeddings_request_queue
|
|
from .. schema import graph_embeddings_response_queue
|
|
|
|
from . endpoint import ServiceEndpoint
|
|
from . requestor import ServiceRequestor
|
|
from . serialize import serialize_value
|
|
|
|
class GraphEmbeddingsQueryRequestor(ServiceRequestor):
|
|
def __init__(self, pulsar_client, timeout, auth):
|
|
|
|
super(GraphEmbeddingsQueryRequestor, self).__init__(
|
|
pulsar_client=pulsar_client,
|
|
request_queue=graph_embeddings_request_queue,
|
|
response_queue=graph_embeddings_response_queue,
|
|
request_schema=GraphEmbeddingsRequest,
|
|
response_schema=GraphEmbeddingsResponse,
|
|
timeout=timeout,
|
|
)
|
|
|
|
def to_request(self, body):
|
|
|
|
limit = int(body.get("limit", 20))
|
|
|
|
return GraphEmbeddingsRequest(
|
|
vectors = body["vectors"],
|
|
limit = limit,
|
|
user = body.get("user", "trustgraph"),
|
|
collection = body.get("collection", "default"),
|
|
)
|
|
|
|
def from_response(self, message):
|
|
|
|
return {
|
|
"entities": [
|
|
serialize_value(ent) for ent in message.entities
|
|
]
|
|
}, True
|
|
|