mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Feature/flow management cli (#346)
Flow management API + various flow management commands trustgraph-cli/scripts/tg-delete-flow-class trustgraph-cli/scripts/tg-get-flow-class trustgraph-cli/scripts/tg-put-flow-class trustgraph-cli/scripts/tg-show-flow-classes trustgraph-cli/scripts/tg-show-flows trustgraph-cli/scripts/tg-start-flow trustgraph-cli/scripts/tg-stop-flow
This commit is contained in:
parent
a9197d11ee
commit
3b021720c5
39 changed files with 1706 additions and 335 deletions
210
trustgraph-flow/trustgraph/config/service/flow.py
Normal file
210
trustgraph-flow/trustgraph/config/service/flow.py
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
|
||||
from trustgraph.schema import FlowResponse, Error
|
||||
import json
|
||||
|
||||
class FlowConfig:
|
||||
def __init__(self, config):
|
||||
|
||||
self.config = config
|
||||
|
||||
async def handle_list_classes(self, msg):
|
||||
|
||||
names = list(self.config["flow-classes"].keys())
|
||||
|
||||
return FlowResponse(
|
||||
error = None,
|
||||
class_names = names,
|
||||
)
|
||||
|
||||
async def handle_get_class(self, msg):
|
||||
|
||||
return FlowResponse(
|
||||
error = None,
|
||||
class_definition = self.config["flow-classes"][msg.class_name],
|
||||
)
|
||||
|
||||
async def handle_put_class(self, msg):
|
||||
|
||||
self.config["flow-classes"][msg.class_name] = msg.class_definition
|
||||
|
||||
await self.config.push()
|
||||
|
||||
return FlowResponse(
|
||||
error = None,
|
||||
)
|
||||
|
||||
async def handle_delete_class(self, msg):
|
||||
|
||||
print(msg)
|
||||
|
||||
del self.config["flow-classes"][msg.class_name]
|
||||
|
||||
await self.config.push()
|
||||
|
||||
return FlowResponse(
|
||||
error = None,
|
||||
)
|
||||
|
||||
async def handle_list_flows(self, msg):
|
||||
|
||||
names = list(self.config["flows"].keys())
|
||||
|
||||
return FlowResponse(
|
||||
error = None,
|
||||
flow_ids = names,
|
||||
)
|
||||
|
||||
async def handle_get_flow(self, msg):
|
||||
|
||||
flow = self.config["flows"][msg.flow_id]
|
||||
|
||||
return FlowResponse(
|
||||
error = None,
|
||||
flow = flow,
|
||||
)
|
||||
|
||||
async def handle_start_flow(self, msg):
|
||||
|
||||
if msg.class_name is None:
|
||||
raise RuntimeError("No class name")
|
||||
|
||||
if msg.flow_id is None:
|
||||
raise RuntimeError("No flow ID")
|
||||
|
||||
if msg.flow_id in self.config["flows"]:
|
||||
raise RuntimeError("Flow already exists")
|
||||
|
||||
if msg.description is None:
|
||||
raise RuntimeError("No description")
|
||||
|
||||
if msg.class_name not in self.config["flow-classes"]:
|
||||
raise RuntimeError("Class does not exist")
|
||||
|
||||
def repl_template(tmp):
|
||||
return tmp.replace(
|
||||
"{class}", msg.class_name
|
||||
).replace(
|
||||
"{id}", msg.flow_id
|
||||
)
|
||||
|
||||
cls = json.loads(self.config["flow-classes"][msg.class_name])
|
||||
|
||||
for kind in ("class", "flow"):
|
||||
|
||||
for k, v in cls[kind].items():
|
||||
|
||||
processor, variant = k.split(":", 1)
|
||||
|
||||
variant = repl_template(variant)
|
||||
|
||||
v = {
|
||||
repl_template(k2): repl_template(v2)
|
||||
for k2, v2 in v.items()
|
||||
}
|
||||
|
||||
if processor in self.config["flows-active"]:
|
||||
target = json.loads(self.config["flows-active"][processor])
|
||||
else:
|
||||
target = {}
|
||||
|
||||
if variant not in target:
|
||||
target[variant] = v
|
||||
|
||||
self.config["flows-active"][processor] = json.dumps(target)
|
||||
|
||||
self.config["flows"][msg.flow_id] = json.dumps({
|
||||
"description": msg.description,
|
||||
"class-name": msg.class_name,
|
||||
})
|
||||
|
||||
await self.config.push()
|
||||
|
||||
return FlowResponse(
|
||||
error = None,
|
||||
)
|
||||
|
||||
async def handle_stop_flow(self, msg):
|
||||
|
||||
if msg.flow_id is None:
|
||||
raise RuntimeError("No flow ID")
|
||||
|
||||
if msg.flow_id not in self.config["flows"]:
|
||||
raise RuntimeError("Flow ID invalid")
|
||||
|
||||
flow = json.loads(self.config["flows"][msg.flow_id])
|
||||
|
||||
if "class-name" not in flow:
|
||||
raise RuntimeError("Internal error: flow has no flow class")
|
||||
|
||||
class_name = flow["class-name"]
|
||||
|
||||
cls = json.loads(self.config["flow-classes"][class_name])
|
||||
|
||||
def repl_template(tmp):
|
||||
return tmp.replace(
|
||||
"{class}", class_name
|
||||
).replace(
|
||||
"{id}", msg.flow_id
|
||||
)
|
||||
|
||||
for kind in ("flow",):
|
||||
|
||||
for k, v in cls[kind].items():
|
||||
|
||||
processor, variant = k.split(":", 1)
|
||||
|
||||
variant = repl_template(variant)
|
||||
|
||||
if processor in self.config["flows-active"]:
|
||||
target = json.loads(self.config["flows-active"][processor])
|
||||
else:
|
||||
target = {}
|
||||
|
||||
if variant in target:
|
||||
del target[variant]
|
||||
|
||||
self.config["flows-active"][processor] = json.dumps(target)
|
||||
|
||||
if msg.flow_id in self.config["flows"]:
|
||||
del self.config["flows"][msg.flow_id]
|
||||
|
||||
await self.config.push()
|
||||
|
||||
return FlowResponse(
|
||||
error = None,
|
||||
)
|
||||
|
||||
async def handle(self, msg):
|
||||
|
||||
print("Handle message ", msg.operation)
|
||||
|
||||
if msg.operation == "list-classes":
|
||||
resp = await self.handle_list_classes(msg)
|
||||
elif msg.operation == "get-class":
|
||||
resp = await self.handle_get_class(msg)
|
||||
elif msg.operation == "put-class":
|
||||
resp = await self.handle_put_class(msg)
|
||||
elif msg.operation == "delete-class":
|
||||
resp = await self.handle_delete_class(msg)
|
||||
elif msg.operation == "list-flows":
|
||||
resp = await self.handle_list_flows(msg)
|
||||
elif msg.operation == "get-flow":
|
||||
resp = await self.handle_get_flow(msg)
|
||||
elif msg.operation == "start-flow":
|
||||
resp = await self.handle_start_flow(msg)
|
||||
elif msg.operation == "stop-flow":
|
||||
resp = await self.handle_stop_flow(msg)
|
||||
else:
|
||||
|
||||
resp = FlowResponse(
|
||||
value=None,
|
||||
directory=None,
|
||||
values=None,
|
||||
error=Error(
|
||||
type = "bad-operation",
|
||||
message = "Bad operation"
|
||||
)
|
||||
)
|
||||
|
||||
return resp
|
||||
|
||||
|
|
@ -5,81 +5,139 @@ Config service. Manages system global configuration state
|
|||
|
||||
from pulsar.schema import JsonSchema
|
||||
|
||||
from trustgraph.schema import ConfigRequest, ConfigResponse, ConfigPush
|
||||
from trustgraph.schema import Error
|
||||
|
||||
from trustgraph.schema import ConfigRequest, ConfigResponse, ConfigPush
|
||||
from trustgraph.schema import config_request_queue, config_response_queue
|
||||
from trustgraph.schema import config_push_queue
|
||||
|
||||
from trustgraph.schema import FlowRequest, FlowResponse
|
||||
from trustgraph.schema import flow_request_queue, flow_response_queue
|
||||
|
||||
from trustgraph.log_level import LogLevel
|
||||
from trustgraph.base import AsyncProcessor, Consumer, Producer
|
||||
|
||||
from . config import Configuration
|
||||
from . flow import FlowConfig
|
||||
|
||||
from ... base import ProcessorMetrics, ConsumerMetrics, ProducerMetrics
|
||||
from ... base import Consumer, Producer
|
||||
|
||||
default_ident = "config-svc"
|
||||
|
||||
default_request_queue = config_request_queue
|
||||
default_response_queue = config_response_queue
|
||||
default_push_queue = config_push_queue
|
||||
default_config_request_queue = config_request_queue
|
||||
default_config_response_queue = config_response_queue
|
||||
default_config_push_queue = config_push_queue
|
||||
|
||||
default_flow_request_queue = flow_request_queue
|
||||
default_flow_response_queue = flow_response_queue
|
||||
|
||||
class Processor(AsyncProcessor):
|
||||
|
||||
def __init__(self, **params):
|
||||
|
||||
request_queue = params.get("request_queue", default_request_queue)
|
||||
response_queue = params.get("response_queue", default_response_queue)
|
||||
push_queue = params.get("push_queue", default_push_queue)
|
||||
config_request_queue = params.get(
|
||||
"config_request_queue", default_config_request_queue
|
||||
)
|
||||
config_response_queue = params.get(
|
||||
"config_response_queue", default_config_response_queue
|
||||
)
|
||||
config_push_queue = params.get(
|
||||
"config_push_queue", default_config_push_queue
|
||||
)
|
||||
|
||||
flow_request_queue = params.get(
|
||||
"flow_request_queue", default_flow_request_queue
|
||||
)
|
||||
flow_response_queue = params.get(
|
||||
"flow_response_queue", default_flow_response_queue
|
||||
)
|
||||
|
||||
id = params.get("id")
|
||||
|
||||
request_schema = ConfigRequest
|
||||
response_schema = ConfigResponse
|
||||
push_schema = ConfigResponse
|
||||
flow_request_schema = FlowRequest
|
||||
flow_response_schema = FlowResponse
|
||||
|
||||
super(Processor, self).__init__(
|
||||
**params | {
|
||||
"request_schema": request_schema.__name__,
|
||||
"response_schema": response_schema.__name__,
|
||||
"push_schema": push_schema.__name__,
|
||||
"config_request_schema": ConfigRequest.__name__,
|
||||
"config_response_schema": ConfigResponse.__name__,
|
||||
"config_push_schema": ConfigPush.__name__,
|
||||
"flow_request_schema": FlowRequest.__name__,
|
||||
"flow_response_schema": FlowResponse.__name__,
|
||||
}
|
||||
)
|
||||
|
||||
request_metrics = ConsumerMetrics(id + "-request")
|
||||
response_metrics = ProducerMetrics(id + "-response")
|
||||
push_metrics = ProducerMetrics(id + "-push")
|
||||
|
||||
self.push_pub = Producer(
|
||||
client = self.client,
|
||||
topic = push_queue,
|
||||
schema = ConfigPush,
|
||||
metrics = push_metrics,
|
||||
config_request_metrics = ConsumerMetrics(
|
||||
processor = self.id, flow = None, name = "config-request"
|
||||
)
|
||||
config_response_metrics = ProducerMetrics(
|
||||
processor = self.id, flow = None, name = "config-response"
|
||||
)
|
||||
config_push_metrics = ProducerMetrics(
|
||||
processor = self.id, flow = None, name = "config-push"
|
||||
)
|
||||
|
||||
self.response_pub = Producer(
|
||||
client = self.client,
|
||||
topic = response_queue,
|
||||
schema = ConfigResponse,
|
||||
metrics = response_metrics,
|
||||
flow_request_metrics = ConsumerMetrics(
|
||||
processor = self.id, flow = None, name = "flow-request"
|
||||
)
|
||||
flow_response_metrics = ProducerMetrics(
|
||||
processor = self.id, flow = None, name = "flow-response"
|
||||
)
|
||||
|
||||
self.subs = Consumer(
|
||||
self.config_request_consumer = Consumer(
|
||||
taskgroup = self.taskgroup,
|
||||
client = self.client,
|
||||
client = self.pulsar_client,
|
||||
flow = None,
|
||||
topic = request_queue,
|
||||
topic = config_request_queue,
|
||||
subscriber = id,
|
||||
schema = request_schema,
|
||||
handler = self.on_message,
|
||||
metrics = request_metrics,
|
||||
schema = ConfigRequest,
|
||||
handler = self.on_config_request,
|
||||
metrics = config_request_metrics,
|
||||
)
|
||||
|
||||
self.config_response_producer = Producer(
|
||||
client = self.pulsar_client,
|
||||
topic = config_response_queue,
|
||||
schema = ConfigResponse,
|
||||
metrics = config_response_metrics,
|
||||
)
|
||||
|
||||
self.config_push_producer = Producer(
|
||||
client = self.pulsar_client,
|
||||
topic = config_push_queue,
|
||||
schema = ConfigPush,
|
||||
metrics = config_push_metrics,
|
||||
)
|
||||
|
||||
self.flow_request_consumer = Consumer(
|
||||
taskgroup = self.taskgroup,
|
||||
client = self.pulsar_client,
|
||||
flow = None,
|
||||
topic = flow_request_queue,
|
||||
subscriber = id,
|
||||
schema = FlowRequest,
|
||||
handler = self.on_flow_request,
|
||||
metrics = flow_request_metrics,
|
||||
)
|
||||
|
||||
self.flow_response_producer = Producer(
|
||||
client = self.pulsar_client,
|
||||
topic = flow_response_queue,
|
||||
schema = FlowResponse,
|
||||
metrics = flow_response_metrics,
|
||||
)
|
||||
|
||||
self.config = Configuration(self.push)
|
||||
self.flow = FlowConfig(self.config)
|
||||
|
||||
print("Service initialised.")
|
||||
|
||||
async def start(self):
|
||||
|
||||
await self.push()
|
||||
await self.subs.start()
|
||||
await self.config_request_consumer.start()
|
||||
await self.flow_request_consumer.start()
|
||||
|
||||
async def push(self):
|
||||
|
||||
|
|
@ -92,11 +150,11 @@ class Processor(AsyncProcessor):
|
|||
error = None,
|
||||
)
|
||||
|
||||
await self.push_pub.send(resp)
|
||||
await self.config_push_producer.send(resp)
|
||||
|
||||
print("Pushed version ", self.config.version)
|
||||
|
||||
async def on_message(self, msg, consumer, flow):
|
||||
async def on_config_request(self, msg, consumer, flow):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -109,19 +167,54 @@ class Processor(AsyncProcessor):
|
|||
|
||||
resp = await self.config.handle(v)
|
||||
|
||||
await self.response_pub.send(resp, properties={"id": id})
|
||||
await self.config_response_producer.send(
|
||||
resp, properties={"id": id}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
resp = ConfigResponse(
|
||||
error=Error(
|
||||
type = "unexpected-error",
|
||||
type = "config-error",
|
||||
message = str(e),
|
||||
),
|
||||
text=None,
|
||||
)
|
||||
|
||||
await self.response_pub.send(resp, properties={"id": id})
|
||||
await self.config_response_producer.send(
|
||||
resp, properties={"id": id}
|
||||
)
|
||||
|
||||
async def on_flow_request(self, msg, consumer, flow):
|
||||
|
||||
try:
|
||||
|
||||
v = msg.value()
|
||||
|
||||
# Sender-produced ID
|
||||
id = msg.properties()["id"]
|
||||
|
||||
print(f"Handling {id}...", flush=True)
|
||||
|
||||
resp = await self.flow.handle(v)
|
||||
|
||||
await self.flow_response_producer.send(
|
||||
resp, properties={"id": id}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
||||
resp = FlowResponse(
|
||||
error=Error(
|
||||
type = "flow-error",
|
||||
message = str(e),
|
||||
),
|
||||
text=None,
|
||||
)
|
||||
|
||||
await self.flow_response_producer.send(
|
||||
resp, properties={"id": id}
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def add_args(parser):
|
||||
|
|
@ -129,21 +222,33 @@ class Processor(AsyncProcessor):
|
|||
AsyncProcessor.add_args(parser)
|
||||
|
||||
parser.add_argument(
|
||||
'-q', '--request-queue',
|
||||
default=default_request_queue,
|
||||
help=f'Request queue (default: {default_request_queue})'
|
||||
'--config-request-queue',
|
||||
default=default_config_request_queue,
|
||||
help=f'Config request queue (default: {default_config_request_queue})'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-r', '--response-queue',
|
||||
default=default_response_queue,
|
||||
help=f'Response queue {default_response_queue}',
|
||||
'--config-response-queue',
|
||||
default=default_config_response_queue,
|
||||
help=f'Config response queue {default_config_response_queue}',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--push-queue',
|
||||
default=default_push_queue,
|
||||
help=f'Config push queue (default: {default_push_queue})'
|
||||
default=default_config_push_queue,
|
||||
help=f'Config push queue (default: {default_config_push_queue})'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--flow-request-queue',
|
||||
default=default_flow_request_queue,
|
||||
help=f'Flow request queue (default: {default_flow_request_queue})'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--flow-response-queue',
|
||||
default=default_flow_response_queue,
|
||||
help=f'Flow response queue {default_flow_response_queue}',
|
||||
)
|
||||
|
||||
def run():
|
||||
|
|
|
|||
51
trustgraph-flow/trustgraph/gateway/flow.py
Normal file
51
trustgraph-flow/trustgraph/gateway/flow.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
|
||||
from .. schema import FlowRequest, FlowResponse, ConfigKey, ConfigValue
|
||||
from .. schema import flow_request_queue
|
||||
from .. schema import flow_response_queue
|
||||
|
||||
from . endpoint import ServiceEndpoint
|
||||
from . requestor import ServiceRequestor
|
||||
|
||||
class FlowRequestor(ServiceRequestor):
|
||||
def __init__(self, pulsar_client, timeout, auth):
|
||||
|
||||
super(FlowRequestor, self).__init__(
|
||||
pulsar_client=pulsar_client,
|
||||
request_queue=flow_request_queue,
|
||||
response_queue=flow_response_queue,
|
||||
request_schema=FlowRequest,
|
||||
response_schema=FlowResponse,
|
||||
timeout=timeout,
|
||||
)
|
||||
|
||||
def to_request(self, body):
|
||||
|
||||
return FlowRequest(
|
||||
operation = body.get("operation", None),
|
||||
class_name = body.get("class-name", None),
|
||||
class_definition = body.get("class-definition", None),
|
||||
description = body.get("description", None),
|
||||
flow_id = body.get("flow-id", None),
|
||||
)
|
||||
|
||||
def from_response(self, message):
|
||||
|
||||
response = { }
|
||||
|
||||
if message.class_names is not None:
|
||||
response["class-names"] = message.class_names
|
||||
|
||||
if message.flow_ids is not None:
|
||||
response["flow-ids"] = message.flow_ids
|
||||
|
||||
if message.class_definition is not None:
|
||||
response["class-definition"] = message.class_definition
|
||||
|
||||
if message.flow is not None:
|
||||
response["flow"] = message.flow
|
||||
|
||||
if message.description is not None:
|
||||
response["description"] = message.description
|
||||
|
||||
return response, True
|
||||
|
||||
|
|
@ -5,7 +5,6 @@ import uuid
|
|||
from aiohttp import web, WSMsgType
|
||||
|
||||
from . socket import SocketEndpoint
|
||||
from . text_completion import TextCompletionRequestor
|
||||
|
||||
MAX_OUTSTANDING_REQUESTS = 15
|
||||
WORKER_CLOSE_WAIT = 0.01
|
||||
|
|
|
|||
|
|
@ -25,28 +25,30 @@ from .. log_level import LogLevel
|
|||
|
||||
from . serialize import to_subgraph
|
||||
from . running import Running
|
||||
from . text_completion import TextCompletionRequestor
|
||||
from . prompt import PromptRequestor
|
||||
from . graph_rag import GraphRagRequestor
|
||||
from . document_rag import DocumentRagRequestor
|
||||
from . triples_query import TriplesQueryRequestor
|
||||
from . graph_embeddings_query import GraphEmbeddingsQueryRequestor
|
||||
from . embeddings import EmbeddingsRequestor
|
||||
from . encyclopedia import EncyclopediaRequestor
|
||||
from . agent import AgentRequestor
|
||||
from . dbpedia import DbpediaRequestor
|
||||
from . internet_search import InternetSearchRequestor
|
||||
from . librarian import LibrarianRequestor
|
||||
|
||||
#from . text_completion import TextCompletionRequestor
|
||||
#from . prompt import PromptRequestor
|
||||
#from . graph_rag import GraphRagRequestor
|
||||
#from . document_rag import DocumentRagRequestor
|
||||
#from . triples_query import TriplesQueryRequestor
|
||||
#from . graph_embeddings_query import GraphEmbeddingsQueryRequestor
|
||||
#from . embeddings import EmbeddingsRequestor
|
||||
#from . encyclopedia import EncyclopediaRequestor
|
||||
#from . agent import AgentRequestor
|
||||
#from . dbpedia import DbpediaRequestor
|
||||
#from . internet_search import InternetSearchRequestor
|
||||
#from . librarian import LibrarianRequestor
|
||||
from . config import ConfigRequestor
|
||||
from . triples_stream import TriplesStreamEndpoint
|
||||
from . graph_embeddings_stream import GraphEmbeddingsStreamEndpoint
|
||||
from . document_embeddings_stream import DocumentEmbeddingsStreamEndpoint
|
||||
from . triples_load import TriplesLoadEndpoint
|
||||
from . graph_embeddings_load import GraphEmbeddingsLoadEndpoint
|
||||
from . document_embeddings_load import DocumentEmbeddingsLoadEndpoint
|
||||
from . flow import FlowRequestor
|
||||
#from . triples_stream import TriplesStreamEndpoint
|
||||
#from . graph_embeddings_stream import GraphEmbeddingsStreamEndpoint
|
||||
#from . document_embeddings_stream import DocumentEmbeddingsStreamEndpoint
|
||||
#from . triples_load import TriplesLoadEndpoint
|
||||
#from . graph_embeddings_load import GraphEmbeddingsLoadEndpoint
|
||||
#from . document_embeddings_load import DocumentEmbeddingsLoadEndpoint
|
||||
from . mux import MuxEndpoint
|
||||
from . document_load import DocumentLoadSender
|
||||
from . text_load import TextLoadSender
|
||||
#from . document_load import DocumentLoadSender
|
||||
#from . text_load import TextLoadSender
|
||||
from . metrics import MetricsEndpoint
|
||||
|
||||
from . endpoint import ServiceEndpoint
|
||||
|
|
@ -105,157 +107,165 @@ class Api:
|
|||
self.auth = Authenticator(allow_all=True)
|
||||
|
||||
self.services = {
|
||||
"text-completion": TextCompletionRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"prompt": PromptRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"graph-rag": GraphRagRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"document-rag": DocumentRagRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"triples-query": TriplesQueryRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"graph-embeddings-query": GraphEmbeddingsQueryRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"embeddings": EmbeddingsRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"agent": AgentRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"librarian": LibrarianRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
# "text-completion": TextCompletionRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "prompt": PromptRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "graph-rag": GraphRagRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "document-rag": DocumentRagRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "triples-query": TriplesQueryRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "graph-embeddings-query": GraphEmbeddingsQueryRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "embeddings": EmbeddingsRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "agent": AgentRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "librarian": LibrarianRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
"config": ConfigRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"encyclopedia": EncyclopediaRequestor(
|
||||
"flow": FlowRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"dbpedia": DbpediaRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"internet-search": InternetSearchRequestor(
|
||||
pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
auth = self.auth,
|
||||
),
|
||||
"document-load": DocumentLoadSender(
|
||||
pulsar_client=self.pulsar_client,
|
||||
),
|
||||
"text-load": TextLoadSender(
|
||||
pulsar_client=self.pulsar_client,
|
||||
),
|
||||
# "encyclopedia": EncyclopediaRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "dbpedia": DbpediaRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "internet-search": InternetSearchRequestor(
|
||||
# pulsar_client=self.pulsar_client, timeout=self.timeout,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# "document-load": DocumentLoadSender(
|
||||
# pulsar_client=self.pulsar_client,
|
||||
# ),
|
||||
# "text-load": TextLoadSender(
|
||||
# pulsar_client=self.pulsar_client,
|
||||
# ),
|
||||
}
|
||||
|
||||
self.endpoints = [
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/text-completion", auth=self.auth,
|
||||
requestor = self.services["text-completion"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/prompt", auth=self.auth,
|
||||
requestor = self.services["prompt"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/graph-rag", auth=self.auth,
|
||||
requestor = self.services["graph-rag"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/document-rag", auth=self.auth,
|
||||
requestor = self.services["document-rag"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/triples-query", auth=self.auth,
|
||||
requestor = self.services["triples-query"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/graph-embeddings-query",
|
||||
auth=self.auth,
|
||||
requestor = self.services["graph-embeddings-query"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/embeddings", auth=self.auth,
|
||||
requestor = self.services["embeddings"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/agent", auth=self.auth,
|
||||
requestor = self.services["agent"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/librarian", auth=self.auth,
|
||||
requestor = self.services["librarian"],
|
||||
),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/text-completion", auth=self.auth,
|
||||
# requestor = self.services["text-completion"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/prompt", auth=self.auth,
|
||||
# requestor = self.services["prompt"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/graph-rag", auth=self.auth,
|
||||
# requestor = self.services["graph-rag"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/document-rag", auth=self.auth,
|
||||
# requestor = self.services["document-rag"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/triples-query", auth=self.auth,
|
||||
# requestor = self.services["triples-query"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/graph-embeddings-query",
|
||||
# auth=self.auth,
|
||||
# requestor = self.services["graph-embeddings-query"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/embeddings", auth=self.auth,
|
||||
# requestor = self.services["embeddings"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/agent", auth=self.auth,
|
||||
# requestor = self.services["agent"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/librarian", auth=self.auth,
|
||||
# requestor = self.services["librarian"],
|
||||
# ),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/config", auth=self.auth,
|
||||
requestor = self.services["config"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/encyclopedia", auth=self.auth,
|
||||
requestor = self.services["encyclopedia"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/dbpedia", auth=self.auth,
|
||||
requestor = self.services["dbpedia"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/internet-search", auth=self.auth,
|
||||
requestor = self.services["internet-search"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/load/document", auth=self.auth,
|
||||
requestor = self.services["document-load"],
|
||||
),
|
||||
ServiceEndpoint(
|
||||
endpoint_path = "/api/v1/load/text", auth=self.auth,
|
||||
requestor = self.services["text-load"],
|
||||
),
|
||||
TriplesStreamEndpoint(
|
||||
pulsar_client=self.pulsar_client,
|
||||
auth = self.auth,
|
||||
),
|
||||
GraphEmbeddingsStreamEndpoint(
|
||||
pulsar_client=self.pulsar_client,
|
||||
auth = self.auth,
|
||||
),
|
||||
DocumentEmbeddingsStreamEndpoint(
|
||||
pulsar_client=self.pulsar_client,
|
||||
auth = self.auth,
|
||||
),
|
||||
TriplesLoadEndpoint(
|
||||
pulsar_client=self.pulsar_client,
|
||||
auth = self.auth,
|
||||
),
|
||||
GraphEmbeddingsLoadEndpoint(
|
||||
pulsar_client=self.pulsar_client,
|
||||
auth = self.auth,
|
||||
),
|
||||
DocumentEmbeddingsLoadEndpoint(
|
||||
pulsar_client=self.pulsar_client,
|
||||
auth = self.auth,
|
||||
),
|
||||
MuxEndpoint(
|
||||
pulsar_client=self.pulsar_client,
|
||||
auth = self.auth,
|
||||
services = self.services,
|
||||
endpoint_path = "/api/v1/flow", auth=self.auth,
|
||||
requestor = self.services["flow"],
|
||||
),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/encyclopedia", auth=self.auth,
|
||||
# requestor = self.services["encyclopedia"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/dbpedia", auth=self.auth,
|
||||
# requestor = self.services["dbpedia"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/internet-search", auth=self.auth,
|
||||
# requestor = self.services["internet-search"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/load/document", auth=self.auth,
|
||||
# requestor = self.services["document-load"],
|
||||
# ),
|
||||
# ServiceEndpoint(
|
||||
# endpoint_path = "/api/v1/load/text", auth=self.auth,
|
||||
# requestor = self.services["text-load"],
|
||||
# ),
|
||||
# TriplesStreamEndpoint(
|
||||
# pulsar_client=self.pulsar_client,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# GraphEmbeddingsStreamEndpoint(
|
||||
# pulsar_client=self.pulsar_client,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# DocumentEmbeddingsStreamEndpoint(
|
||||
# pulsar_client=self.pulsar_client,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# TriplesLoadEndpoint(
|
||||
# pulsar_client=self.pulsar_client,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# GraphEmbeddingsLoadEndpoint(
|
||||
# pulsar_client=self.pulsar_client,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# DocumentEmbeddingsLoadEndpoint(
|
||||
# pulsar_client=self.pulsar_client,
|
||||
# auth = self.auth,
|
||||
# ),
|
||||
# MuxEndpoint(
|
||||
# pulsar_client=self.pulsar_client,
|
||||
# auth = self.auth,
|
||||
# services = self.services,
|
||||
# ),
|
||||
MetricsEndpoint(
|
||||
endpoint_path = "/api/v1/metrics",
|
||||
prometheus_url = self.prometheus_url,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue