Skip to content

Commit

Permalink
Weather Agent Sample: Only include tool_call_id to chatbot.append if …
Browse files Browse the repository at this point in the history
…it's set (#771)

Co-authored-by: Sydney Runkle <[email protected]>
  • Loading branch information
chug2k and sydney-runkle authored Feb 3, 2025
1 parent 42c70c0 commit fa1625d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions examples/pydantic_ai_examples/weather_agent_gradio.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ async def stream_from_agent(prompt: str, chatbot: list[dict], past_messages: lis
if hasattr(call.args, 'args_json')
else json.dumps(call.args.args_dict)
)
metadata = {
'title': f'🛠️ Using {TOOL_TO_DISPLAY_NAME[call.tool_name]}',
}
if call.tool_call_id is not None:
metadata['id'] = {call.tool_call_id}

gr_message = {
'role': 'assistant',
'content': 'Parameters: ' + call_args,
'metadata': {
'title': f'🛠️ Using {TOOL_TO_DISPLAY_NAME[call.tool_name]}',
'id': call.tool_call_id,
},
'metadata': metadata,
}
chatbot.append(gr_message)
if isinstance(call, ToolReturnPart):
Expand Down

0 comments on commit fa1625d

Please sign in to comment.