mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-18 03:45:12 +02:00
Concurrency implemented in more services (#409)
This commit is contained in:
parent
e10e9d2295
commit
5364b1fad5
6 changed files with 63 additions and 6 deletions
|
|
@ -11,20 +11,26 @@ from .. exceptions import TooManyRequests
|
||||||
from .. base import FlowProcessor, ConsumerSpec, ProducerSpec
|
from .. base import FlowProcessor, ConsumerSpec, ProducerSpec
|
||||||
|
|
||||||
default_ident = "embeddings"
|
default_ident = "embeddings"
|
||||||
|
default_concurrency = 1
|
||||||
|
|
||||||
class EmbeddingsService(FlowProcessor):
|
class EmbeddingsService(FlowProcessor):
|
||||||
|
|
||||||
def __init__(self, **params):
|
def __init__(self, **params):
|
||||||
|
|
||||||
id = params.get("id")
|
id = params.get("id")
|
||||||
|
concurrency = params.get("concurrency", 1)
|
||||||
|
|
||||||
super(EmbeddingsService, self).__init__(**params | { "id": id })
|
super(EmbeddingsService, self).__init__(**params | {
|
||||||
|
"id": id,
|
||||||
|
"concurrency": concurrency,
|
||||||
|
})
|
||||||
|
|
||||||
self.register_specification(
|
self.register_specification(
|
||||||
ConsumerSpec(
|
ConsumerSpec(
|
||||||
name = "request",
|
name = "request",
|
||||||
schema = EmbeddingsRequest,
|
schema = EmbeddingsRequest,
|
||||||
handler = self.on_request
|
handler = self.on_request,
|
||||||
|
concurrency = concurrency,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -84,6 +90,13 @@ class EmbeddingsService(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})'
|
||||||
|
)
|
||||||
|
|
||||||
FlowProcessor.add_args(parser)
|
FlowProcessor.add_args(parser)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ class LlmService(FlowProcessor):
|
||||||
'-c', '--concurrency',
|
'-c', '--concurrency',
|
||||||
type=int,
|
type=int,
|
||||||
default=default_concurrency,
|
default=default_concurrency,
|
||||||
help=f'LLM max output tokens (default: {default_concurrency})'
|
help=f'Concurrent processing threads (default: {default_concurrency})'
|
||||||
)
|
)
|
||||||
|
|
||||||
FlowProcessor.add_args(parser)
|
FlowProcessor.add_args(parser)
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,19 @@ RDF_LABEL_VALUE = Value(value=RDF_LABEL, is_uri=True)
|
||||||
SUBJECT_OF_VALUE = Value(value=SUBJECT_OF, is_uri=True)
|
SUBJECT_OF_VALUE = Value(value=SUBJECT_OF, is_uri=True)
|
||||||
|
|
||||||
default_ident = "kg-extract-definitions"
|
default_ident = "kg-extract-definitions"
|
||||||
|
default_concurrency = 1
|
||||||
|
|
||||||
class Processor(FlowProcessor):
|
class Processor(FlowProcessor):
|
||||||
|
|
||||||
def __init__(self, **params):
|
def __init__(self, **params):
|
||||||
|
|
||||||
id = params.get("id")
|
id = params.get("id")
|
||||||
|
concurrency = params.get("concurrency", 1)
|
||||||
|
|
||||||
super(Processor, self).__init__(
|
super(Processor, self).__init__(
|
||||||
**params | {
|
**params | {
|
||||||
"id": id,
|
"id": id,
|
||||||
|
"concurrency": concurrency,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -38,7 +41,8 @@ class Processor(FlowProcessor):
|
||||||
ConsumerSpec(
|
ConsumerSpec(
|
||||||
name = "input",
|
name = "input",
|
||||||
schema = Chunk,
|
schema = Chunk,
|
||||||
handler = self.on_message
|
handler = self.on_message,
|
||||||
|
concurrency = concurrency,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -190,6 +194,13 @@ 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})'
|
||||||
|
)
|
||||||
|
|
||||||
FlowProcessor.add_args(parser)
|
FlowProcessor.add_args(parser)
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|
|
||||||
|
|
@ -20,16 +20,19 @@ RDF_LABEL_VALUE = Value(value=RDF_LABEL, is_uri=True)
|
||||||
SUBJECT_OF_VALUE = Value(value=SUBJECT_OF, is_uri=True)
|
SUBJECT_OF_VALUE = Value(value=SUBJECT_OF, is_uri=True)
|
||||||
|
|
||||||
default_ident = "kg-extract-relationships"
|
default_ident = "kg-extract-relationships"
|
||||||
|
default_concurrency = 1
|
||||||
|
|
||||||
class Processor(FlowProcessor):
|
class Processor(FlowProcessor):
|
||||||
|
|
||||||
def __init__(self, **params):
|
def __init__(self, **params):
|
||||||
|
|
||||||
id = params.get("id")
|
id = params.get("id")
|
||||||
|
concurrency = params.get("concurrency", 1)
|
||||||
|
|
||||||
super(Processor, self).__init__(
|
super(Processor, self).__init__(
|
||||||
**params | {
|
**params | {
|
||||||
"id": id,
|
"id": id,
|
||||||
|
"concurrency": concurrency,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -37,7 +40,8 @@ class Processor(FlowProcessor):
|
||||||
ConsumerSpec(
|
ConsumerSpec(
|
||||||
name = "input",
|
name = "input",
|
||||||
schema = Chunk,
|
schema = Chunk,
|
||||||
handler = self.on_message
|
handler = self.on_message,
|
||||||
|
concurrency = concurrency,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -192,6 +196,13 @@ 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})'
|
||||||
|
)
|
||||||
|
|
||||||
FlowProcessor.add_args(parser)
|
FlowProcessor.add_args(parser)
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,14 @@ from .... base import ProducerSpec, ConsumerSpec, TextCompletionClientSpec
|
||||||
from . prompt_manager import PromptConfiguration, Prompt, PromptManager
|
from . prompt_manager import PromptConfiguration, Prompt, PromptManager
|
||||||
|
|
||||||
default_ident = "prompt"
|
default_ident = "prompt"
|
||||||
|
default_concurrency = 1
|
||||||
|
|
||||||
class Processor(FlowProcessor):
|
class Processor(FlowProcessor):
|
||||||
|
|
||||||
def __init__(self, **params):
|
def __init__(self, **params):
|
||||||
|
|
||||||
id = params.get("id")
|
id = params.get("id")
|
||||||
|
concurrency = params.get("concurrency", 1)
|
||||||
|
|
||||||
# Config key for prompts
|
# Config key for prompts
|
||||||
self.config_key = params.get("config_type", "prompt")
|
self.config_key = params.get("config_type", "prompt")
|
||||||
|
|
@ -31,6 +33,7 @@ class Processor(FlowProcessor):
|
||||||
super(Processor, self).__init__(
|
super(Processor, self).__init__(
|
||||||
**params | {
|
**params | {
|
||||||
"id": id,
|
"id": id,
|
||||||
|
"concurrency": concurrency,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -38,7 +41,8 @@ class Processor(FlowProcessor):
|
||||||
ConsumerSpec(
|
ConsumerSpec(
|
||||||
name = "request",
|
name = "request",
|
||||||
schema = PromptRequest,
|
schema = PromptRequest,
|
||||||
handler = self.on_request
|
handler = self.on_request,
|
||||||
|
concurrency = concurrency,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -219,6 +223,13 @@ 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})'
|
||||||
|
)
|
||||||
|
|
||||||
FlowProcessor.add_args(parser)
|
FlowProcessor.add_args(parser)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,14 @@ from ... base import PromptClientSpec, EmbeddingsClientSpec
|
||||||
from ... base import GraphEmbeddingsClientSpec, TriplesClientSpec
|
from ... base import GraphEmbeddingsClientSpec, TriplesClientSpec
|
||||||
|
|
||||||
default_ident = "graph-rag"
|
default_ident = "graph-rag"
|
||||||
|
default_concurrency = 1
|
||||||
|
|
||||||
class Processor(FlowProcessor):
|
class Processor(FlowProcessor):
|
||||||
|
|
||||||
def __init__(self, **params):
|
def __init__(self, **params):
|
||||||
|
|
||||||
id = params.get("id", default_ident)
|
id = params.get("id", default_ident)
|
||||||
|
concurrency = params.get("concurrency", 1)
|
||||||
|
|
||||||
entity_limit = params.get("entity_limit", 50)
|
entity_limit = params.get("entity_limit", 50)
|
||||||
triple_limit = params.get("triple_limit", 30)
|
triple_limit = params.get("triple_limit", 30)
|
||||||
|
|
@ -26,6 +28,7 @@ class Processor(FlowProcessor):
|
||||||
super(Processor, self).__init__(
|
super(Processor, self).__init__(
|
||||||
**params | {
|
**params | {
|
||||||
"id": id,
|
"id": id,
|
||||||
|
"concurrency": concurrency,
|
||||||
"entity_limit": entity_limit,
|
"entity_limit": entity_limit,
|
||||||
"triple_limit": triple_limit,
|
"triple_limit": triple_limit,
|
||||||
"max_subgraph_size": max_subgraph_size,
|
"max_subgraph_size": max_subgraph_size,
|
||||||
|
|
@ -43,6 +46,7 @@ class Processor(FlowProcessor):
|
||||||
name = "request",
|
name = "request",
|
||||||
schema = GraphRagQuery,
|
schema = GraphRagQuery,
|
||||||
handler = self.on_request,
|
handler = self.on_request,
|
||||||
|
concurrency = concurrency,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -157,6 +161,13 @@ 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})'
|
||||||
|
)
|
||||||
|
|
||||||
FlowProcessor.add_args(parser)
|
FlowProcessor.add_args(parser)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue