docs: Add section on tool choice (#31692)

- Make it known in the concepts guide that tool choice is available
This commit is contained in:
Mason Daugherty 2025-06-23 11:31:49 -04:00 committed by GitHub
parent ba38997c7a
commit af2188b848
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -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:

View File

@ -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."
]
},
{