Skip to content

Commit af2188b

Browse files
authored
docs: Add section on tool choice (#31692)
- Make it known in the concepts guide that tool choice is available
1 parent ba38997 commit af2188b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

docs/docs/concepts/tool_calling.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ For more details on usage, see our [how-to guides](/docs/how_to/#tools)!
137137

138138
:::
139139

140+
## Forcing tool use
141+
142+
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.
143+
144+
:::info[Further reading]
145+
146+
* See our [how-to guide](/docs/how_to/tool_choice) on forcing tool use.
147+
148+
:::
149+
140150
## Best practices
141151

142152
When designing [tools](/docs/concepts/tools/) to be used by a model, it is important to keep in mind that:

docs/docs/how_to/tool_choice.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"cell_type": "markdown",
100100
"metadata": {},
101101
"source": [
102-
"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."
102+
"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."
103103
]
104104
},
105105
{

0 commit comments

Comments
 (0)