From 75eb02e546675de3d86e5a308a497b9bc34a6c70 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Thu, 4 Dec 2025 20:00:11 +0000 Subject: [PATCH] Fixing invoke_prompt --- .../trustgraph/cli/invoke_prompt.py | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/trustgraph-cli/trustgraph/cli/invoke_prompt.py b/trustgraph-cli/trustgraph/cli/invoke_prompt.py index b1eba5aa..09cc9043 100644 --- a/trustgraph-cli/trustgraph/cli/invoke_prompt.py +++ b/trustgraph-cli/trustgraph/cli/invoke_prompt.py @@ -31,36 +31,16 @@ def query(url, flow_id, template_id, variables, streaming=True, token=None): ) if streaming: - full_response = {"text": "", "object": ""} - - # Stream output + # Stream output (prompt yields strings directly) for chunk in response: - content = chunk.content - if content: - print(content, end="", flush=True) - full_response["text"] += content - - # Check if this is an object response (JSON) - if hasattr(chunk, 'object') and chunk.object: - full_response["object"] = chunk.object - - # Handle final output - if full_response["text"]: - # Add final newline after streaming text - print() - elif full_response["object"]: - # Print JSON object (pretty-printed) - print(json.dumps(json.loads(full_response["object"]), indent=4)) + if chunk: + print(chunk, end="", flush=True) + # Add final newline after streaming + print() else: - # Non-streaming: handle response - if isinstance(response, str): - print(response) - elif isinstance(response, dict): - if "text" in response: - print(response["text"]) - elif "object" in response: - print(json.dumps(json.loads(response["object"]), indent=4)) + # Non-streaming: print complete response + print(response) finally: # Clean up socket connection