Flow class -> flow blueprint

This commit is contained in:
Cyber MacGeddon 2026-01-14 11:35:53 +00:00
parent 7672815349
commit ba45b59f7b
4 changed files with 38 additions and 38 deletions

View file

@ -28,42 +28,42 @@ class Flow:
def id(self, id="default"):
return FlowInstance(api=self, id=id)
def list_classes(self):
def list_blueprints(self):
# The input consists of system and prompt strings
input = {
"operation": "list-classes",
"operation": "list-blueprints",
}
return self.request(request = input)["class-names"]
return self.request(request = input)["blueprint-names"]
def get_class(self, class_name):
def get_blueprint(self, blueprint_name):
# The input consists of system and prompt strings
input = {
"operation": "get-class",
"class-name": class_name,
"operation": "get-blueprint",
"blueprint-name": blueprint_name,
}
return json.loads(self.request(request = input)["class-definition"])
return json.loads(self.request(request = input)["blueprint-definition"])
def put_class(self, class_name, definition):
def put_blueprint(self, blueprint_name, definition):
# The input consists of system and prompt strings
input = {
"operation": "put-class",
"class-name": class_name,
"class-definition": json.dumps(definition),
"operation": "put-blueprint",
"blueprint-name": blueprint_name,
"blueprint-definition": json.dumps(definition),
}
self.request(request = input)
def delete_class(self, class_name):
def delete_blueprint(self, blueprint_name):
# The input consists of system and prompt strings
input = {
"operation": "delete-class",
"class-name": class_name,
"operation": "delete-blueprint",
"blueprint-name": blueprint_name,
}
self.request(request = input)
@ -87,13 +87,13 @@ class Flow:
return json.loads(self.request(request = input)["flow"])
def start(self, class_name, id, description, parameters=None):
def start(self, blueprint_name, id, description, parameters=None):
# The input consists of system and prompt strings
input = {
"operation": "start-flow",
"flow-id": id,
"class-name": class_name,
"blueprint-name": blueprint_name,
"description": description,
}

View file

@ -1,5 +1,5 @@
"""
Starts a processing flow using a defined flow class.
Starts a processing flow using a defined flow blueprint.
Parameters can be provided in three ways:
1. As key=value pairs: --param model=gpt-4 --param temp=0.7
@ -19,12 +19,12 @@ import json
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
def start_flow(url, class_name, flow_id, description, parameters=None, token=None):
def start_flow(url, blueprint_name, flow_id, description, parameters=None, token=None):
api = Api(url, token=token).flow()
api.start(
class_name = class_name,
blueprint_name = blueprint_name,
id = flow_id,
description = description,
parameters = parameters,
@ -50,9 +50,9 @@ def main():
)
parser.add_argument(
'-n', '--class-name',
'-n', '--blueprint-name',
required=True,
help=f'Flow class name',
help=f'Flow blueprint name',
)
parser.add_argument(
@ -115,7 +115,7 @@ def main():
start_flow(
url = args.api_url,
class_name = args.class_name,
blueprint_name = args.blueprint_name,
flow_id = args.flow_id,
description = args.description,
parameters = parameters,

View file

@ -194,21 +194,21 @@ def check_processors(url: str, min_processors: int, timeout: int, token: Optiona
return False, f"Processor check error: {e}"
def check_flow_classes(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
"""Check if flow classes are loaded."""
def check_flow_blueprints(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
"""Check if flow blueprints are loaded."""
try:
api = Api(url, token=token, timeout=timeout)
flow_api = api.flow()
classes = flow_api.list_classes()
blueprints = flow_api.list_blueprints()
if classes and len(classes) > 0:
return True, f"Found {len(classes)} flow class(es)"
if blueprints and len(blueprints) > 0:
return True, f"Found {len(blueprints)} flow blueprint(s)"
else:
return False, "No flow classes found"
return False, "No flow blueprints found"
except Exception as e:
return False, f"Flow classes check error: {e}"
return False, f"Flow blueprints check error: {e}"
def check_flows(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]:
@ -416,8 +416,8 @@ def main():
)
checker.run_check(
"Flow Classes",
check_flow_classes,
"Flow Blueprints",
check_flow_blueprints,
args.api_url,
args.check_timeout,
args.token

View file

@ -102,7 +102,7 @@ class FlowConfig:
async def handle_list_blueprints(self, msg):
names = list(await self.config.get("flow-blueprints").keys())
names = list(await self.config.get("flow-blueprint").keys())
return FlowResponse(
error = None,
@ -114,13 +114,13 @@ class FlowConfig:
return FlowResponse(
error = None,
blueprint_definition = await self.config.get(
"flow-blueprints"
"flow-blueprint"
).get(msg.blueprint_name),
)
async def handle_put_blueprint(self, msg):
await self.config.get("flow-blueprints").put(
await self.config.get("flow-blueprint").put(
msg.blueprint_name, msg.blueprint_definition
)
@ -136,7 +136,7 @@ class FlowConfig:
logger.debug(f"Flow config message: {msg}")
await self.config.get("flow-blueprints").delete(msg.blueprint_name)
await self.config.get("flow-blueprint").delete(msg.blueprint_name)
await self.config.inc_version()
@ -181,11 +181,11 @@ class FlowConfig:
if msg.description is None:
raise RuntimeError("No description")
if msg.blueprint_name not in await self.config.get("flow-blueprints").keys():
if msg.blueprint_name not in await self.config.get("flow-blueprint").keys():
raise RuntimeError("Blueprint does not exist")
cls = json.loads(
await self.config.get("flow-blueprints").get(msg.blueprint_name)
await self.config.get("flow-blueprint").get(msg.blueprint_name)
)
# Resolve parameters by merging user-provided values with defaults
@ -292,7 +292,7 @@ class FlowConfig:
blueprint_name = flow["blueprint-name"]
parameters = flow.get("parameters", {})
cls = json.loads(await self.config.get("flow-blueprints").get(blueprint_name))
cls = json.loads(await self.config.get("flow-blueprint").get(blueprint_name))
def repl_template(tmp):
result = tmp.replace(