fromlangchain.agentsimportcreate_agentdefget_weather(city:str)->str:"""Get weather for a given city."""returnf"It's always sunny in{city}!"agent=create_agent(model="gpt-5-nano",tools=[get_weather],)forchunkinagent.stream({"messages":[{"role":"user","content":"What is the weather in SF?"}]},stream_mode="updates",):forstep,datainchunk.items():print(f"step:{step}")print(f"content:{data['messages'][-1].content_blocks}")
响应信息
step:model content:[{'type':'tool_call','name':'get_weather','args':{'city':'San Francisco'},'id':'call_OW2NYNsNSKhRZpjW0wm2Aszd'}]step:tools content:[{'type':'text','text':"It's always sunny in San Francisco!"}]step:model content:[{'type':'text','text':'It's always sunnyinSan Francisco!'}]
fromlangchain.agentsimportcreate_agentdefget_weather(city:str)->str:"""Get weather for a given city."""returnf"It's always sunny in{city}!"agent=create_agent(model="gpt-5-nano",tools=[get_weather],)fortoken,metadatainagent.stream({"messages":[{"role":"user","content":"What is the weather in SF?"}]},stream_mode="messages"
3分钟掌握图片格式转换:Save Image as Type完整使用指南 【免费下载链接】Save-Image-as-Type Save Image as Type is an chrome extension which add Save as PNG / JPG / WebP to the context menu of image. 项目地址: https://gitcode.com/gh_mirrors/sa/Save…
终极科研利器:Obsidian学术研究模板的完整指南 【免费下载链接】obsidian_vault_template_for_researcher This is an vault template for researchers using obsidian. 项目地址: https://gitcode.com/gh_mirrors/ob/obsidian_vault_template_for_researcher …