mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-26 00:46:22 +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
|
||||
|
||||
default_ident = "embeddings"
|
||||
default_concurrency = 1
|
||||
|
||||
class EmbeddingsService(FlowProcessor):
|
||||
|
||||
def __init__(self, **params):
|
||||
|
||||
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(
|
||||
ConsumerSpec(
|
||||
name = "request",
|
||||
schema = EmbeddingsRequest,
|
||||
handler = self.on_request
|
||||
handler = self.on_request,
|
||||
concurrency = concurrency,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -84,6 +90,13 @@ class EmbeddingsService(FlowProcessor):
|
|||
@staticmethod
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class LlmService(FlowProcessor):
|
|||
'-c', '--concurrency',
|
||||
type=int,
|
||||
default=default_concurrency,
|
||||
help=f'LLM max output tokens (default: {default_concurrency})'
|
||||
help=f'Concurrent processing threads (default: {default_concurrency})'
|
||||
)
|
||||
|
||||
FlowProcessor.add_args(parser)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue