flow parameters (#526)

* Flow parameter tech spec

* Flow configurable parameters implemented
This commit is contained in:
cybermaggedon 2025-09-23 23:18:04 +01:00 committed by GitHub
parent 3b0b13d74d
commit dc2fa1f31e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 538 additions and 26 deletions

View file

@ -74,6 +74,13 @@ def show_flows(url):
table.append(("id", id))
table.append(("class", flow.get("class-name", "")))
table.append(("desc", flow.get("description", "")))
# Display parameters if they exist
parameters = flow.get("parameters", {})
if parameters:
param_str = json.dumps(parameters, indent=2)
table.append(("parameters", param_str))
table.append(("queue", describe_interfaces(interface_defs, flow)))
print(tabulate.tabulate(

View file

@ -10,7 +10,7 @@ import json
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
def start_flow(url, class_name, flow_id, description):
def start_flow(url, class_name, flow_id, description, parameters=None):
api = Api(url).flow()
@ -18,6 +18,7 @@ def start_flow(url, class_name, flow_id, description):
class_name = class_name,
id = flow_id,
description = description,
parameters = parameters,
)
def main():
@ -51,15 +52,34 @@ def main():
help=f'Flow description',
)
parser.add_argument(
'-p', '--parameters',
help=f'Flow parameters as JSON string (e.g., \'{"model": "gpt-4", "temp": 0.7}\')',
)
parser.add_argument(
'--parameters-file',
help=f'Path to JSON file containing flow parameters',
)
args = parser.parse_args()
try:
# Parse parameters from command line arguments
parameters = None
if args.parameters_file:
with open(args.parameters_file, 'r') as f:
parameters = json.load(f)
elif args.parameters:
parameters = json.loads(args.parameters)
start_flow(
url = args.api_url,
class_name = args.class_name,
flow_id = args.flow_id,
description = args.description,
parameters = parameters,
)
except Exception as e: