mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-21 19:21:03 +02:00
Triples stream working
This commit is contained in:
parent
3d307cfb89
commit
873f7a84e4
4 changed files with 10 additions and 13 deletions
|
|
@ -25,7 +25,7 @@ request_response_dispatchers = {
|
|||
}
|
||||
|
||||
receive_dispatchers = {
|
||||
"embeddings": TriplesStream,
|
||||
"triples-store": TriplesStream,
|
||||
}
|
||||
|
||||
class TestDispatcher:
|
||||
|
|
@ -127,6 +127,9 @@ class DispatcherManager:
|
|||
flow = params.get("flow")
|
||||
kind = params.get("kind")
|
||||
|
||||
# FIXME: What?!?!
|
||||
kind += "-store"
|
||||
|
||||
if flow not in self.flows:
|
||||
raise RuntimeError("Invalid flow")
|
||||
|
||||
|
|
@ -150,7 +153,7 @@ class DispatcherManager:
|
|||
ws = ws,
|
||||
running = running,
|
||||
# FIXME!
|
||||
queue = qconfig["response"],
|
||||
queue = qconfig,
|
||||
consumer = f"api-gateway-{flow}-{kind}-request",
|
||||
subscriber = f"api-gateway-{flow}-{kind}-request",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import asyncio
|
|||
import queue
|
||||
import uuid
|
||||
|
||||
from ... schema import Triples, EmbeddingsResponse
|
||||
from ... schema import Triples
|
||||
from ... base import Subscriber
|
||||
|
||||
from . serialize import serialize_triples
|
||||
|
|
@ -37,8 +37,7 @@ class TriplesStream:
|
|||
subs = Subscriber(
|
||||
client = self.pulsar_client, topic = self.queue,
|
||||
consumer_name = self.consumer, subscription = self.subscriber,
|
||||
# schema = Triples
|
||||
schema = EmbeddingsResponse
|
||||
schema = Triples
|
||||
)
|
||||
|
||||
await subs.start()
|
||||
|
|
@ -50,12 +49,7 @@ class TriplesStream:
|
|||
try:
|
||||
|
||||
resp = await asyncio.wait_for(q.get(), timeout=0.5)
|
||||
# await self.ws.send_json(serialize_triples(resp))
|
||||
|
||||
print("GOT MESSAGE!!!")
|
||||
|
||||
|
||||
await self.ws.send_json(str(resp))
|
||||
await self.ws.send_json(serialize_triples(resp))
|
||||
|
||||
except TimeoutError:
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue