From af2188b8488cc7edff1d8fa510f18c9ca5614161 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 23 Jun 2025 11:31:49 -0400 Subject: [PATCH] docs: Add section on tool choice (#31692) - Make it known in the concepts guide that tool choice is available --- docs/docs/concepts/tool_calling.mdx | 10 ++++++++++ docs/docs/how_to/tool_choice.ipynb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/docs/concepts/tool_calling.mdx b/docs/docs/concepts/tool_calling.mdx index 69051bd8d87..7f48142f411 100644 --- a/docs/docs/concepts/tool_calling.mdx +++ b/docs/docs/concepts/tool_calling.mdx @@ -137,6 +137,16 @@ For more details on usage, see our [how-to guides](/docs/how_to/#tools)! ::: +## Forcing tool use + +By default, the model has the freedom to choose which tool to use based on the user's input. However, in certain scenarios, you might want to influence the model's decision-making process. LangChain allows you to enforce tool choice (using `tool_choice`), ensuring the model uses either a particular tool or *any* tool from a given list. This is useful for structuring the model's behavior and guiding it towards a desired outcome. + +:::info[Further reading] + +* See our [how-to guide](/docs/how_to/tool_choice) on forcing tool use. + +::: + ## Best practices When designing [tools](/docs/concepts/tools/) to be used by a model, it is important to keep in mind that: diff --git a/docs/docs/how_to/tool_choice.ipynb b/docs/docs/how_to/tool_choice.ipynb index 0a7ad581e0d..2f5d67df933 100644 --- a/docs/docs/how_to/tool_choice.ipynb +++ b/docs/docs/how_to/tool_choice.ipynb @@ -99,7 +99,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We can also just force our tool to select at least one of our tools by passing in the \"any\" (or \"required\" which is OpenAI specific) keyword to the `tool_choice` parameter." + "We can also just force our tool to select at least one of our tools by passing in the \"any\" (or \"required\" [which is OpenAI specific](https://python.langchain.com/api_reference/openai/chat_models/langchain_openai.chat_models.base.BaseChatOpenAI.html#langchain_openai.chat_models.base.BaseChatOpenAI.bind_tools)) keyword to the `tool_choice` parameter." ] }, {