mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-26 17:06:22 +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
|
|
@ -86,13 +86,13 @@ class FlowConfig:
|
|||
if msg.flow_id is None:
|
||||
raise RuntimeError("No flow ID")
|
||||
|
||||
if msg.flow_id in await self.config.get("flows").values():
|
||||
if msg.flow_id in await self.config.get("flows").keys():
|
||||
raise RuntimeError("Flow already exists")
|
||||
|
||||
if msg.description is None:
|
||||
raise RuntimeError("No description")
|
||||
|
||||
if msg.class_name not in await self.config.get("flow-classes").values():
|
||||
if msg.class_name not in await self.config.get("flow-classes").keys():
|
||||
raise RuntimeError("Class does not exist")
|
||||
|
||||
cls = json.loads(
|
||||
|
|
@ -104,6 +104,7 @@ class FlowConfig:
|
|||
|
||||
# Apply parameter substitution to template replacement function
|
||||
def repl_template_with_params(tmp):
|
||||
|
||||
result = tmp.replace(
|
||||
"{class}", msg.class_name
|
||||
).replace(
|
||||
|
|
@ -112,6 +113,7 @@ class FlowConfig:
|
|||
# Apply parameter substitutions
|
||||
for param_name, param_value in parameters.items():
|
||||
result = result.replace(f"{{{param_name}}}", str(param_value))
|
||||
|
||||
return result
|
||||
|
||||
for kind in ("class", "flow"):
|
||||
|
|
@ -127,12 +129,17 @@ class FlowConfig:
|
|||
for k2, v2 in v.items()
|
||||
}
|
||||
|
||||
flac = await self.config.get("flows-active").values()
|
||||
if processor in flac:
|
||||
target = json.loads(flac[processor])
|
||||
flac = await self.config.get("flows-active").get(processor)
|
||||
if flac is not None:
|
||||
target = json.loads(flac)
|
||||
else:
|
||||
target = {}
|
||||
|
||||
# The condition if variant not in target: means it only adds
|
||||
# the configuration if the variant doesn't already exist.
|
||||
# If "everything" already exists in the target with old
|
||||
# values, they won't update.
|
||||
|
||||
if variant not in target:
|
||||
target[variant] = v
|
||||
|
||||
|
|
@ -212,10 +219,10 @@ class FlowConfig:
|
|||
|
||||
variant = repl_template(variant)
|
||||
|
||||
flac = await self.config.get("flows-active").values()
|
||||
flac = await self.config.get("flows-active").get(processor)
|
||||
|
||||
if processor in flac:
|
||||
target = json.loads(flac[processor])
|
||||
if flac is not None:
|
||||
target = json.loads(flac)
|
||||
else:
|
||||
target = {}
|
||||
|
||||
|
|
@ -226,7 +233,7 @@ class FlowConfig:
|
|||
processor, json.dumps(target)
|
||||
)
|
||||
|
||||
if msg.flow_id in await self.config.get("flows").values():
|
||||
if msg.flow_id in await self.config.get("flows").keys():
|
||||
await self.config.get("flows").delete(msg.flow_id)
|
||||
|
||||
await self.config.inc_version()
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ class ConfigTableStore:
|
|||
""")
|
||||
|
||||
self.get_all_stmt = self.cassandra.prepare("""
|
||||
SELECT class, key, value FROM config;
|
||||
SELECT class AS cls, key, value FROM config;
|
||||
""")
|
||||
|
||||
self.get_values_stmt = self.cassandra.prepare("""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue