mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
* Altered API to incorporate Flow IDs, refactored for dynamic start/stop of flows * Gateway: Split endpoint / dispatcher for maintainability
30 lines
868 B
Python
30 lines
868 B
Python
|
|
from ... schema import EmbeddingsRequest, EmbeddingsResponse
|
|
|
|
from . requestor import ServiceRequestor
|
|
|
|
class EmbeddingsRequestor(ServiceRequestor):
|
|
def __init__(
|
|
self, pulsar_client, request_queue, response_queue, timeout,
|
|
consumer, subscriber,
|
|
):
|
|
|
|
super(EmbeddingsRequestor, self).__init__(
|
|
pulsar_client=pulsar_client,
|
|
request_queue=request_queue,
|
|
response_queue=response_queue,
|
|
request_schema=EmbeddingsRequest,
|
|
response_schema=EmbeddingsResponse,
|
|
subscription = subscriber,
|
|
consumer_name = consumer,
|
|
timeout=timeout,
|
|
)
|
|
|
|
def to_request(self, body):
|
|
return EmbeddingsRequest(
|
|
text=body["text"]
|
|
)
|
|
|
|
def from_response(self, message):
|
|
return { "vectors": message.vectors }, True
|
|
|