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:
cybermaggedon 2025-05-02 21:11:50 +01:00 committed by GitHub
parent 450f664b1b
commit a70ae9793a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 1206 additions and 907 deletions

View 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