Concurrency implemented in more services (#409)

This commit is contained in:
cybermaggedon 2025-06-04 11:45:21 +01:00 committed by GitHub
parent e10e9d2295
commit 5364b1fad5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 63 additions and 6 deletions

View file

@ -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)

View file

@ -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)