mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-17 01:01:03 +02:00
Service/endpoint separation
This commit is contained in:
parent
8fbf3cc07d
commit
a243d93db6
2 changed files with 84 additions and 43 deletions
|
|
@ -5,17 +5,15 @@ from pulsar.schema import JsonSchema
|
||||||
import uuid
|
import uuid
|
||||||
from aiohttp import web, WSMsgType
|
from aiohttp import web, WSMsgType
|
||||||
|
|
||||||
from .. schema import GraphEmbeddings
|
|
||||||
from .. schema import graph_embeddings_store_queue
|
|
||||||
|
|
||||||
from . subscriber import Subscriber
|
|
||||||
from . socket import SocketEndpoint
|
from . socket import SocketEndpoint
|
||||||
from . serialize import serialize_graph_embeddings
|
from . text_completion import TextCompletionRequestor
|
||||||
|
|
||||||
class CommandEndpoint(SocketEndpoint):
|
class CommandEndpoint(SocketEndpoint):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, pulsar_host, auth, path="/api/v1/command"
|
self, pulsar_host, auth,
|
||||||
|
services,
|
||||||
|
path="/api/v1/command",
|
||||||
):
|
):
|
||||||
|
|
||||||
super(CommandEndpoint, self).__init__(
|
super(CommandEndpoint, self).__init__(
|
||||||
|
|
@ -24,6 +22,9 @@ class CommandEndpoint(SocketEndpoint):
|
||||||
|
|
||||||
self.pulsar_host=pulsar_host
|
self.pulsar_host=pulsar_host
|
||||||
|
|
||||||
|
# self.text_completion = TextCompletionRequestor(
|
||||||
|
# )
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,22 +31,22 @@ from . serialize import to_subgraph
|
||||||
from . running import Running
|
from . running import Running
|
||||||
from . publisher import Publisher
|
from . publisher import Publisher
|
||||||
from . subscriber import Subscriber
|
from . subscriber import Subscriber
|
||||||
from . endpoint import ServiceEndpoint, MultiResponseServiceEndpoint
|
from . text_completion import TextCompletionRequestor
|
||||||
from . text_completion import TextCompletionEndpoint
|
from . prompt import PromptRequestor
|
||||||
from . prompt import PromptEndpoint
|
from . graph_rag import GraphRagRequestor
|
||||||
from . graph_rag import GraphRagEndpoint
|
from . triples_query import TriplesQueryRequestor
|
||||||
from . triples_query import TriplesQueryEndpoint
|
from . embeddings import EmbeddingsRequestor
|
||||||
from . embeddings import EmbeddingsEndpoint
|
from . encyclopedia import EncyclopediaRequestor
|
||||||
from . encyclopedia import EncyclopediaEndpoint
|
from . agent import AgentRequestor
|
||||||
from . agent import AgentEndpoint
|
from . dbpedia import DbpediaRequestor
|
||||||
from . dbpedia import DbpediaEndpoint
|
from . internet_search import InternetSearchRequestor
|
||||||
from . internet_search import InternetSearchEndpoint
|
|
||||||
from . triples_stream import TriplesStreamEndpoint
|
from . triples_stream import TriplesStreamEndpoint
|
||||||
from . graph_embeddings_stream import GraphEmbeddingsStreamEndpoint
|
from . graph_embeddings_stream import GraphEmbeddingsStreamEndpoint
|
||||||
from . triples_load import TriplesLoadEndpoint
|
from . triples_load import TriplesLoadEndpoint
|
||||||
from . graph_embeddings_load import GraphEmbeddingsLoadEndpoint
|
from . graph_embeddings_load import GraphEmbeddingsLoadEndpoint
|
||||||
from . command import CommandEndpoint
|
from . command import CommandEndpoint
|
||||||
|
|
||||||
|
from . endpoint import ServiceEndpoint, MultiResponseServiceEndpoint
|
||||||
from . auth import Authenticator
|
from . auth import Authenticator
|
||||||
|
|
||||||
logger = logging.getLogger("api")
|
logger = logging.getLogger("api")
|
||||||
|
|
@ -78,42 +78,81 @@ class Api:
|
||||||
else:
|
else:
|
||||||
self.auth = Authenticator(allow_all=True)
|
self.auth = Authenticator(allow_all=True)
|
||||||
|
|
||||||
|
self.services = {
|
||||||
|
"text-completion": TextCompletionRequestor(
|
||||||
|
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
||||||
|
auth = self.auth,
|
||||||
|
),
|
||||||
|
"prompt": PromptRequestor(
|
||||||
|
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
||||||
|
auth = self.auth,
|
||||||
|
),
|
||||||
|
"graph-rag": GraphRagRequestor(
|
||||||
|
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
||||||
|
auth = self.auth,
|
||||||
|
),
|
||||||
|
"triples-query": TriplesQueryRequestor(
|
||||||
|
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
||||||
|
auth = self.auth,
|
||||||
|
),
|
||||||
|
"embeddings": EmbeddingsRequestor(
|
||||||
|
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
||||||
|
auth = self.auth,
|
||||||
|
),
|
||||||
|
"agent": AgentRequestor(
|
||||||
|
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
||||||
|
auth = self.auth,
|
||||||
|
),
|
||||||
|
"encyclopedia": EncyclopediaRequestor(
|
||||||
|
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
||||||
|
auth = self.auth,
|
||||||
|
),
|
||||||
|
"dbpedia": DbpediaRequestor(
|
||||||
|
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
||||||
|
auth = self.auth,
|
||||||
|
),
|
||||||
|
"internet-search": InternetSearchRequestor(
|
||||||
|
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
||||||
|
auth = self.auth,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
self.endpoints = [
|
self.endpoints = [
|
||||||
TextCompletionEndpoint(
|
ServiceEndpoint(
|
||||||
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
endpoint_path = "/api/v1/text-completion", auth=self.auth,
|
||||||
auth = self.auth,
|
requestor = self.services["text-completion"],
|
||||||
),
|
),
|
||||||
PromptEndpoint(
|
ServiceEndpoint(
|
||||||
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
endpoint_path = "/api/v1/prompt", auth=self.auth,
|
||||||
auth = self.auth,
|
requestor = self.services["prompt"],
|
||||||
),
|
),
|
||||||
GraphRagEndpoint(
|
ServiceEndpoint(
|
||||||
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
endpoint_path = "/api/v1/graph-rag", auth=self.auth,
|
||||||
auth = self.auth,
|
requestor = self.services["graph-rag"],
|
||||||
),
|
),
|
||||||
TriplesQueryEndpoint(
|
ServiceEndpoint(
|
||||||
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
endpoint_path = "/api/v1/triples-query", auth=self.auth,
|
||||||
auth = self.auth,
|
requestor = self.services["triples-query"],
|
||||||
),
|
),
|
||||||
EmbeddingsEndpoint(
|
ServiceEndpoint(
|
||||||
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
endpoint_path = "/api/v1/embeddings", auth=self.auth,
|
||||||
auth = self.auth,
|
requestor = self.services["embeddings"],
|
||||||
),
|
),
|
||||||
AgentEndpoint(
|
MultiResponseServiceEndpoint(
|
||||||
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
endpoint_path = "/api/v1/agent", auth=self.auth,
|
||||||
auth = self.auth,
|
requestor = self.services["agent"],
|
||||||
),
|
),
|
||||||
EncyclopediaEndpoint(
|
ServiceEndpoint(
|
||||||
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
endpoint_path = "/api/v1/encyclopedia", auth=self.auth,
|
||||||
auth = self.auth,
|
requestor = self.services["encyclopedia"],
|
||||||
),
|
),
|
||||||
DbpediaEndpoint(
|
ServiceEndpoint(
|
||||||
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
endpoint_path = "/api/v1/dbpedia", auth=self.auth,
|
||||||
auth = self.auth,
|
requestor = self.services["dbpedia"],
|
||||||
),
|
),
|
||||||
InternetSearchEndpoint(
|
ServiceEndpoint(
|
||||||
pulsar_host=self.pulsar_host, timeout=self.timeout,
|
endpoint_path = "/api/v1/internet-search", auth=self.auth,
|
||||||
auth = self.auth,
|
requestor = self.services["internet-search"],
|
||||||
),
|
),
|
||||||
TriplesStreamEndpoint(
|
TriplesStreamEndpoint(
|
||||||
pulsar_host=self.pulsar_host,
|
pulsar_host=self.pulsar_host,
|
||||||
|
|
@ -134,6 +173,7 @@ class Api:
|
||||||
CommandEndpoint(
|
CommandEndpoint(
|
||||||
pulsar_host=self.pulsar_host,
|
pulsar_host=self.pulsar_host,
|
||||||
auth = self.auth,
|
auth = self.auth,
|
||||||
|
services = self.services,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue