mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Complete remaining parameter work (#530)
* Fix CLI typo * Complete flow parameters work, still needs implementation in LLMs
This commit is contained in:
parent
72c9acad30
commit
9a34ab1b93
9 changed files with 69 additions and 48 deletions
|
|
@ -8,7 +8,7 @@ from . subscriber import Subscriber
|
|||
from . metrics import ProcessorMetrics, ConsumerMetrics, ProducerMetrics
|
||||
from . flow_processor import FlowProcessor
|
||||
from . consumer_spec import ConsumerSpec
|
||||
from . setting_spec import SettingSpec
|
||||
from . parameter_spec import ParameterSpec
|
||||
from . producer_spec import ProducerSpec
|
||||
from . subscriber_spec import SubscriberSpec
|
||||
from . request_response_spec import RequestResponseSpec
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class Flow:
|
|||
# Consumers and publishers. Is this a bit untidy?
|
||||
self.consumer = {}
|
||||
|
||||
self.setting = {}
|
||||
self.parameter = {}
|
||||
|
||||
for spec in processor.specifications:
|
||||
spec.add(self, processor, defn)
|
||||
|
|
@ -28,5 +28,5 @@ class Flow:
|
|||
def __call__(self, key):
|
||||
if key in self.producer: return self.producer[key]
|
||||
if key in self.consumer: return self.consumer[key]
|
||||
if key in self.setting: return self.setting[key].value
|
||||
if key in self.parameter: return self.parameter[key].value
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class FlowProcessor(AsyncProcessor):
|
|||
|
||||
# These can be overriden by a derived class:
|
||||
|
||||
# Array of specifications: ConsumerSpec, ProducerSpec, SettingSpec
|
||||
# Array of specifications: ConsumerSpec, ProducerSpec, ParameterSpec
|
||||
self.specifications = []
|
||||
|
||||
logger.info("Service initialised.")
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from prometheus_client import Histogram
|
|||
|
||||
from .. schema import TextCompletionRequest, TextCompletionResponse, Error
|
||||
from .. exceptions import TooManyRequests
|
||||
from .. base import FlowProcessor, ConsumerSpec, ProducerSpec
|
||||
from .. base import FlowProcessor, ConsumerSpec, ProducerSpec, ParameterSpec
|
||||
|
||||
# Module logger
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -56,6 +56,12 @@ class LlmService(FlowProcessor):
|
|||
)
|
||||
)
|
||||
|
||||
self.register_specification(
|
||||
ParameterSpec(
|
||||
name = "model",
|
||||
)
|
||||
)
|
||||
|
||||
if not hasattr(__class__, "text_completion_metric"):
|
||||
__class__.text_completion_metric = Histogram(
|
||||
'text_completion_duration',
|
||||
|
|
@ -74,6 +80,11 @@ class LlmService(FlowProcessor):
|
|||
|
||||
try:
|
||||
|
||||
try:
|
||||
logger.debug(f"MODEL IS {flow('model')}")
|
||||
except:
|
||||
logger.debug(f"CAN'T GET MODEL")
|
||||
|
||||
request = msg.value()
|
||||
|
||||
# Sender-produced ID
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
from . spec import Spec
|
||||
|
||||
class Setting:
|
||||
class Parameter:
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
async def start():
|
||||
|
|
@ -9,11 +9,13 @@ class Setting:
|
|||
async def stop():
|
||||
pass
|
||||
|
||||
class SettingSpec(Spec):
|
||||
class ParameterSpec(Spec):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
def add(self, flow, processor, definition):
|
||||
|
||||
flow.config[self.name] = Setting(definition[self.name])
|
||||
value = definition.get(self.name, None)
|
||||
|
||||
flow.parameter[self.name] = Parameter(value)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue