mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 08:26:21 +02:00
Fix non-streaming (2) (#608)
This commit is contained in:
parent
807f6cc4e2
commit
99f17d1b9d
2 changed files with 36 additions and 6 deletions
|
|
@ -178,11 +178,22 @@ def question(
|
|||
print()
|
||||
|
||||
else:
|
||||
# Non-streaming response
|
||||
if "answer" in response:
|
||||
print(response["answer"])
|
||||
if "error" in response:
|
||||
raise RuntimeError(response["error"])
|
||||
# Non-streaming response - but agents use multipart messaging
|
||||
# so we iterate through the chunks (which are complete messages, not text chunks)
|
||||
for chunk in response:
|
||||
# Display thoughts if verbose
|
||||
if chunk.chunk_type == "thought" and verbose:
|
||||
output(wrap(chunk.content), "\U0001f914 ")
|
||||
print()
|
||||
|
||||
# Display observations if verbose
|
||||
elif chunk.chunk_type == "observation" and verbose:
|
||||
output(wrap(chunk.content), "\U0001f4a1 ")
|
||||
print()
|
||||
|
||||
# Display answer
|
||||
elif chunk.chunk_type == "final-answer" or chunk.chunk_type == "answer":
|
||||
print(chunk.content)
|
||||
|
||||
finally:
|
||||
# Clean up socket connection
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue