mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-23 04:01:02 +02:00
Structuring the service
This commit is contained in:
parent
54631355c4
commit
8596b73039
4 changed files with 25 additions and 28 deletions
|
|
@ -30,4 +30,5 @@ from . agent_service import AgentService
|
||||||
from . graph_rag_client import GraphRagClientSpec
|
from . graph_rag_client import GraphRagClientSpec
|
||||||
from . tool_service import ToolService
|
from . tool_service import ToolService
|
||||||
from . tool_client import ToolClientSpec
|
from . tool_client import ToolClientSpec
|
||||||
|
from . agent_client import AgentClientSpec
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,15 @@ class AgentClient(RequestResponse):
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
class GraphEmbeddingsClientSpec(RequestResponseSpec):
|
class AgentClientSpec(RequestResponseSpec):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, request_name, response_name,
|
self, request_name, response_name,
|
||||||
):
|
):
|
||||||
super(GraphEmbeddingsClientSpec, self).__init__(
|
super(AgentClientSpec, self).__init__(
|
||||||
request_name = request_name,
|
request_name = request_name,
|
||||||
request_schema = GraphEmbeddingsRequest,
|
request_schema = GraphEmbeddingsRequest,
|
||||||
response_name = response_name,
|
response_name = response_name,
|
||||||
response_schema = GraphEmbeddingsResponse,
|
response_schema = GraphEmbeddingsResponse,
|
||||||
impl = GraphEmbeddingsClient,
|
impl = AgentClient,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from .... schema import ConfigRequest, ConfigResponse
|
||||||
from .... rdf import TRUSTGRAPH_ENTITIES, RDF_LABEL, SUBJECT_OF, DEFINITION
|
from .... rdf import TRUSTGRAPH_ENTITIES, RDF_LABEL, SUBJECT_OF, DEFINITION
|
||||||
|
|
||||||
from .... base import FlowProcessor, ConsumerSpec, ProducerSpec
|
from .... base import FlowProcessor, ConsumerSpec, ProducerSpec
|
||||||
from .... base import AgentClientSpec, ConfigClientSpec
|
from .... base import AgentClientSpec
|
||||||
|
|
||||||
default_ident = "kg-extract-relationships"
|
default_ident = "kg-extract-relationships"
|
||||||
default_concurrency = 1
|
default_concurrency = 1
|
||||||
|
|
@ -53,13 +53,6 @@ class Processor(FlowProcessor):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.register_specification(
|
|
||||||
ConfigClientSpec(
|
|
||||||
request_name="config-request",
|
|
||||||
response_name="config-response",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
self.register_specification(
|
self.register_specification(
|
||||||
ProducerSpec(
|
ProducerSpec(
|
||||||
name="triples",
|
name="triples",
|
||||||
|
|
@ -277,6 +270,14 @@ class Processor(FlowProcessor):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_args(parser):
|
def add_args(parser):
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-c', '--concurrency',
|
||||||
|
type=int,
|
||||||
|
default=default_concurrency,
|
||||||
|
help=f'Concurrent processing threads (default: {default_concurrency})'
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--template-id",
|
"--template-id",
|
||||||
type=str,
|
type=str,
|
||||||
|
|
@ -284,19 +285,14 @@ class Processor(FlowProcessor):
|
||||||
help="Template ID to use for agent extraction"
|
help="Template ID to use for agent extraction"
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
parser.add_argument(
|
||||||
def run():
|
'--config-type',
|
||||||
import argparse
|
default="prompt",
|
||||||
from .... base import run_processor
|
help=f'Configuration key for prompts (default: prompt)',
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
description="Agent-based knowledge extractor"
|
|
||||||
)
|
)
|
||||||
Processor.add_args(parser)
|
|
||||||
args = parser.parse_args()
|
FlowProcessor.add_args(parser)
|
||||||
|
|
||||||
processor = Processor(
|
def run():
|
||||||
template_id=args.template_id
|
|
||||||
)
|
Processor.launch(default_ident, __doc__)
|
||||||
|
|
||||||
run_processor(processor)
|
|
||||||
|
|
|
||||||
|
|
@ -230,14 +230,14 @@ class Processor(FlowProcessor):
|
||||||
help=f'Concurrent processing threads (default: {default_concurrency})'
|
help=f'Concurrent processing threads (default: {default_concurrency})'
|
||||||
)
|
)
|
||||||
|
|
||||||
FlowProcessor.add_args(parser)
|
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--config-type',
|
'--config-type',
|
||||||
default="prompt",
|
default="prompt",
|
||||||
help=f'Configuration key for prompts (default: prompt)',
|
help=f'Configuration key for prompts (default: prompt)',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
FlowProcessor.add_args(parser)
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|
||||||
Processor.launch(default_ident, __doc__)
|
Processor.launch(default_ident, __doc__)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue