Skip to content

Commit

Permalink
fix: error when streaming events and using tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Huffman committed Dec 31, 2023
1 parent 5ba41ac commit 7d293c8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nimbusagent/agent/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ def output_post_content(post_content: List[str]):
'tool_calls': tool_calls
})

if self.send_events:
for tool_call in tool_calls:
json_data = json.dumps(tool_call)
yield f"[[[function:{tool_call['name']}:{json_data}]]]"

# Handle tool calls
logging.info("Handling tool calls: %s", tool_calls)
content_send_directly_to_user = []
Expand All @@ -141,6 +136,11 @@ def output_post_content(post_content: List[str]):
continue

func_args = tool_call['function']["arguments"]

if self.send_events:
json_data = json.dumps(func_args)
yield f"[[[function:{func_name}:{json_data}]]]"

func_results = self.function_handler.handle_function_call(func_name, func_args)
if func_results is not None:
if func_results.stream_data and self.send_events:
Expand Down

0 comments on commit 7d293c8

Please sign in to comment.