Skip to content

Commit 57cc515

Browse files
vp777Varnavas
andauthored
Fix weather agent example with UI (#1851)
Co-authored-by: Varnavas <vp@localhost>
1 parent 18a86c7 commit 57cc515

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

examples/pydantic_ai_examples/weather_agent_gradio.py

100644100755
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,12 @@ async def stream_from_agent(prompt: str, chatbot: list[dict], past_messages: lis
3333
for message in result.new_messages():
3434
for call in message.parts:
3535
if isinstance(call, ToolCallPart):
36-
call_args = (
37-
call.args.args_json
38-
if hasattr(call.args, 'args_json')
39-
else json.dumps(call.args.args_dict)
40-
)
36+
call_args = call.args_as_json_str()
4137
metadata = {
4238
'title': f'🛠️ Using {TOOL_TO_DISPLAY_NAME[call.tool_name]}',
4339
}
4440
if call.tool_call_id is not None:
45-
metadata['id'] = {call.tool_call_id}
41+
metadata['id'] = call.tool_call_id
4642

4743
gr_message = {
4844
'role': 'assistant',

0 commit comments

Comments
 (0)