Skip to content

Commit

Permalink
docs: enhance agents.ipynb with parallel tool calls section (#5088)
Browse files Browse the repository at this point in the history
* docs: enhance agents.ipynb with parallel tool calls section

* type ignore
  • Loading branch information
ekzhu authored Jan 17, 2025
1 parent c2a43e8 commit f289e64
Showing 1 changed file with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -220,8 +220,13 @@
"it will return the tool's output as a string in {py:class}`~autogen_agentchat.messages.ToolCallSummaryMessage` in its response.\n",
"If your tool does not return a well-formed string in natural language, you\n",
"can add a reflection step to have the model summarize the tool's output,\n",
"by setting the `reflect_on_tool_use=True` parameter in the {py:class}`~autogen_agentchat.agents.AssistantAgent` constructor.\n",
"\n",
"by setting the `reflect_on_tool_use=True` parameter in the {py:class}`~autogen_agentchat.agents.AssistantAgent` constructor."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Langchain Tools\n",
"\n",
"In addition to custom tools, you can also use tools from the Langchain library\n",
Expand Down Expand Up @@ -280,6 +285,42 @@
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Parallel Tool Calls\n",
"\n",
"Some models support parallel tool calls, which can be useful for tasks that require multiple tools to be called simultaneously.\n",
"By default, if the model client produces multiple tool calls, {py:class}`~autogen_agentchat.agents.AssistantAgent`\n",
"will call the tools in parallel.\n",
"\n",
"You may want to disable parallel tool calls when the tools have side effects that may interfere with each other, or,\n",
"when agent behavior needs to be consistent across different models.\n",
"This should be done at the model client level.\n",
"\n",
"For {py:class}`~autogen_ext.models.openai.OpenAIChatCompletionClient` and {py:class}`~autogen_ext.models.openai.AzureOpenAIChatCompletionClient`,\n",
"set `parallel_tool_calls=False` to disable parallel tool calls."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"model_client_no_parallel_tool_call = OpenAIChatCompletionClient(\n",
" model=\"gpt-4o\",\n",
" parallel_tool_calls=False, # type: ignore\n",
")\n",
"agent_no_parallel_tool_call = AssistantAgent(\n",
" name=\"assistant\",\n",
" model_client=model_client_no_parallel_tool_call,\n",
" tools=[web_search],\n",
" system_message=\"Use tools to solve tasks.\",\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit f289e64

Please sign in to comment.