mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-13 01:02:37 +02:00
Flow API - update gateway (#357)
* Altered API to incorporate Flow IDs, refactored for dynamic start/stop of flows * Gateway: Split endpoint / dispatcher for maintainability
This commit is contained in:
parent
450f664b1b
commit
a70ae9793a
52 changed files with 1206 additions and 907 deletions
36
trustgraph-flow/trustgraph/gateway/dispatch/graph_rag.py
Normal file
36
trustgraph-flow/trustgraph/gateway/dispatch/graph_rag.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
from ... schema import GraphRagQuery, GraphRagResponse
|
||||
|
||||
from . requestor import ServiceRequestor
|
||||
|
||||
class GraphRagRequestor(ServiceRequestor):
|
||||
def __init__(
|
||||
self, pulsar_client, request_queue, response_queue, timeout,
|
||||
consumer, subscriber,
|
||||
):
|
||||
|
||||
super(GraphRagRequestor, self).__init__(
|
||||
pulsar_client=pulsar_client,
|
||||
request_queue=request_queue,
|
||||
response_queue=response_queue,
|
||||
request_schema=GraphRagQuery,
|
||||
response_schema=GraphRagResponse,
|
||||
subscription = subscriber,
|
||||
consumer_name = consumer,
|
||||
timeout=timeout,
|
||||
)
|
||||
|
||||
def to_request(self, body):
|
||||
return GraphRagQuery(
|
||||
query=body["query"],
|
||||
user=body.get("user", "trustgraph"),
|
||||
collection=body.get("collection", "default"),
|
||||
entity_limit=int(body.get("entity-limit", 50)),
|
||||
triple_limit=int(body.get("triple-limit", 30)),
|
||||
max_subgraph_size=int(body.get("max-subgraph-size", 1000)),
|
||||
max_path_length=int(body.get("max-path-length", 2)),
|
||||
)
|
||||
|
||||
def from_response(self, message):
|
||||
return { "response": message.response }, True
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue