From 4e064422595daf27d4b1f52cbcc93d7283a05d06 Mon Sep 17 00:00:00 2001 From: Eric Zhu Date: Fri, 4 Oct 2024 18:00:34 -0700 Subject: [PATCH] Update notebook --- .../guides/tool_use.ipynb | 49 ++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/python/packages/autogen-core/docs/src/agentchat-user-guide/guides/tool_use.ipynb b/python/packages/autogen-core/docs/src/agentchat-user-guide/guides/tool_use.ipynb index 40caf3a2469..1c254305282 100644 --- a/python/packages/autogen-core/docs/src/agentchat-user-guide/guides/tool_use.ipynb +++ b/python/packages/autogen-core/docs/src/agentchat-user-guide/guides/tool_use.ipynb @@ -17,7 +17,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -29,7 +29,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -42,18 +42,43 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 6, "metadata": {}, "outputs": [ { - "ename": "TypeError", - "evalue": "ToolUseAssistantAgent.__init__() got an unexpected keyword argument 'tool_schema'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m assistant \u001b[38;5;241m=\u001b[39m \u001b[43mToolUseAssistantAgent\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mWeather_Assistant\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel_client\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mOpenAIChatCompletionClient\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodel\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgpt-4o-mini\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[43mtool_schema\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[43mget_weather_tool\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mschema\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5\u001b[0m \u001b[43m)\u001b[49m\n\u001b[1;32m 6\u001b[0m team \u001b[38;5;241m=\u001b[39m RoundRobinGroupChat([assistant], tools\u001b[38;5;241m=\u001b[39m[get_weather_tool])\n\u001b[1;32m 7\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m team\u001b[38;5;241m.\u001b[39mrun(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWhat\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124ms the weather in New York?\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", - "\u001b[0;31mTypeError\u001b[0m: ToolUseAssistantAgent.__init__() got an unexpected keyword argument 'tool_schema'" + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "--------------------------------------------------------------------------- \n", + "\u001b[91m[2024-10-04T17:59:55.737430]:\u001b[0m\n", + "\n", + "What's the weather in New York?\n", + "From: user" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "--------------------------------------------------------------------------- \n", + "\u001b[91m[2024-10-04T17:59:56.310787], Weather_Assistant:\u001b[0m\n", + "\n", + "[FunctionCall(id='call_zxmdHPEQ1QMd2NwvYUSgxxDV', arguments='{\"city\":\"New York\"}', name='get_weather')]\n", + "From: Weather_Assistant\n", + "--------------------------------------------------------------------------- \n", + "\u001b[91m[2024-10-04T17:59:56.312084], tool_agent_for_Weather_Assistant:\u001b[0m\n", + "\n", + "[FunctionExecutionResult(content='Sunny', call_id='call_zxmdHPEQ1QMd2NwvYUSgxxDV')]\n", + "From: tool_agent_for_Weather_Assistant\n", + "--------------------------------------------------------------------------- \n", + "\u001b[91m[2024-10-04T17:59:56.767874], Weather_Assistant:\u001b[0m\n", + "\n", + "The weather in New York is sunny. \n", + "\n", + "TERMINATE\n", + "From: Weather_Assistant" ] } ], @@ -65,7 +90,7 @@ ")\n", "team = RoundRobinGroupChat([assistant])\n", "result = await team.run(\"What's the weather in New York?\")\n", - "print(result)" + "# print(result)" ] } ],