trustgraph/trustgraph-flow/trustgraph/gateway/graph_rag.py
Cyber MacGeddon 612b1234b4 Fixed a problem with the packages, api/__init__.py appeared in both
trustgraph-flow and trustgraph-base, moved the gateway stuff into a
different directory.
2024-12-06 13:04:11 +00:00

31 lines
973 B
Python

from ... schema import GraphRagQuery, GraphRagResponse
from ... schema import graph_rag_request_queue
from ... schema import graph_rag_response_queue
from . endpoint import ServiceEndpoint
class GraphRagEndpoint(ServiceEndpoint):
def __init__(self, pulsar_host, timeout, auth):
super(GraphRagEndpoint, self).__init__(
pulsar_host=pulsar_host,
request_queue=graph_rag_request_queue,
response_queue=graph_rag_response_queue,
request_schema=GraphRagQuery,
response_schema=GraphRagResponse,
endpoint_path="/api/v1/graph-rag",
timeout=timeout,
auth=auth,
)
def to_request(self, body):
return GraphRagQuery(
query=body["query"],
user=body.get("user", "trustgraph"),
collection=body.get("collection", "default"),
)
def from_response(self, message):
return { "response": message.response }