Skip to content

Commit 27c1214

Browse files
authored
docs[patch]: In conceptual docs explain constraints on ToolMessage (#26792)
Minor clarification
1 parent 3a1b925 commit 27c1214

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

docs/docs/concepts.mdx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ These also have corresponding async methods that should be used with [asyncio](h
116116

117117
The **input type** and **output type** varies by component:
118118

119-
| Component | Input Type | Output Type |
120-
| --- | --- | --- |
121-
| Prompt | Dictionary | PromptValue |
122-
| ChatModel | Single string, list of chat messages or a PromptValue | ChatMessage |
123-
| LLM | Single string, list of chat messages or a PromptValue | String |
124-
| OutputParser | The output of an LLM or ChatModel | Depends on the parser |
125-
| Retriever | Single string | List of Documents |
126-
| Tool | Single string or dictionary, depending on the tool | Depends on the tool |
119+
| Component | Input Type | Output Type |
120+
|--------------|-------------------------------------------------------|-----------------------|
121+
| Prompt | Dictionary | PromptValue |
122+
| ChatModel | Single string, list of chat messages or a PromptValue | ChatMessage |
123+
| LLM | Single string, list of chat messages or a PromptValue | String |
124+
| OutputParser | The output of an LLM or ChatModel | Depends on the parser |
125+
| Retriever | Single string | List of Documents |
126+
| Tool | Single string or dictionary, depending on the tool | Depends on the tool |
127127

128128

129129
All runnables expose input and output **schemas** to inspect the inputs and outputs:
@@ -236,7 +236,7 @@ This is where information like log-probs and token usage may be stored.
236236

237237
**`tool_calls`**
238238

239-
These represent a decision from an language model to call a tool. They are included as part of an `AIMessage` output.
239+
These represent a decision from a language model to call a tool. They are included as part of an `AIMessage` output.
240240
They can be accessed from there with the `.tool_calls` property.
241241

242242
This property returns a list of `ToolCall`s. A `ToolCall` is a dictionary with the following arguments:
@@ -256,6 +256,8 @@ This represents a message with role "tool", which contains the result of calling
256256
- a `tool_call_id` field which conveys the id of the call to the tool that was called to produce this result.
257257
- an `artifact` field which can be used to pass along arbitrary artifacts of the tool execution which are useful to track but which should not be sent to the model.
258258

259+
With most chat models, a `ToolMessage` can only appear in the chat history after an `AIMessage` that has a populated `tool_calls` field.
260+
259261
#### (Legacy) FunctionMessage
260262

261263
This is a legacy message type, corresponding to OpenAI's legacy function-calling API. `ToolMessage` should be used instead to correspond to the updated tool-calling API.

0 commit comments

Comments
 (0)