Skip to content

Commit aa79e61

Browse files
LiqinruiGliqinrui
andauthored
[Docs] Improve reasoning_out docs (#4901)
* [Docs] Improve reasoning_out docs * [Docs] Improve reasoning_out docs * [Docs] Improve reasoning_out docs --------- Co-authored-by: liqinrui <[email protected]>
1 parent 07b21d2 commit aa79e61

File tree

2 files changed

+158
-8
lines changed

2 files changed

+158
-8
lines changed

docs/features/reasoning_output.md

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
Reasoning models return an additional `reasoning_content` field in their output, which contains the reasoning steps that led to the final conclusion.
66

77
## Supported Models
8-
| Model Name | Parser Name | Eable_thinking by Default |
9-
|----------------|----------------|---------------------------|
10-
| baidu/ERNIE-4.5-VL-424B-A47B-Paddle | ernie-45-vl ||
11-
| baidu/ERNIE-4.5-VL-28B-A3B-Paddle | ernie-45-vl ||
8+
| Model Name | Parser Name | Eable_thinking by Default | Tool Calling |
9+
|---------------|-------------|---------|---------|
10+
| baidu/ERNIE-4.5-VL-424B-A47B-Paddle | ernie-45-vl |||
11+
| baidu/ERNIE-4.5-VL-28B-A3B-Paddle | ernie-45-vl |||
12+
| baidu/ERNIE-4.5-21B-A3B-Thinking | ernie-x1 | ✅ no off supported ||
1213

1314
The reasoning model requires a specified parser to extract reasoning content. The reasoning mode can be disabled by setting the `"enable_thinking": false` parameter.
1415

@@ -81,3 +82,78 @@ for chunk in chat_response:
8182
print(chunk.choices[0].delta, end='')
8283
print("\n")
8384
```
85+
## Tool Calling
86+
The reasoning content is also available when both tool calling and the reasoning parser are enabled. Additionally, tool calling only parses functions from the `content` field, not from the `reasoning_content`.
87+
88+
Model request example:
89+
```bash
90+
curl -X POST "http://0.0.0.0:8390/v1/chat/completions" \
91+
-H "Content-Type: application/json" \
92+
-d '{
93+
"messages": [
94+
{
95+
"role": "user",
96+
"content": "Get the current weather in BeiJing"
97+
}
98+
],
99+
"tools": [
100+
{
101+
"type": "function",
102+
"function": {
103+
"name": "get_weather",
104+
"description": "Determine weather in my location",
105+
"parameters": {
106+
"type": "object",
107+
"properties": {
108+
"location": {
109+
"type": "string",
110+
"description": "The city and state e.g. San Francisco, CA"
111+
},
112+
"unit": {
113+
"type": "string",
114+
"enum": [
115+
"c",
116+
"f"
117+
]
118+
}
119+
},
120+
"additionalProperties": false,
121+
"required": [
122+
"location",
123+
"unit"
124+
]
125+
},
126+
"strict": true
127+
}
128+
}],
129+
"stream": false
130+
}'
131+
```
132+
Model output example
133+
134+
```json
135+
{
136+
"choices": [
137+
{
138+
"index": 0,
139+
"message": {
140+
"role": "assistant",
141+
"content": "",
142+
"reasoning_content": "The user asks about ...",
143+
"tool_calls": [
144+
{
145+
"id": "chatcmpl-tool-311b9bda34274722afc654c55c8ce6a0",
146+
"type": "function",
147+
"function": {
148+
"name": "get_weather",
149+
"arguments": "{\"location\": \"BeiJing\", \"unit\": \"c\"}"
150+
}
151+
}
152+
]
153+
},
154+
"finish_reason": "tool_calls"
155+
}
156+
]
157+
}
158+
```
159+
More reference documentation related to tool calling usage: [Tool Calling](./tool_calling.md)

docs/zh/features/reasoning_output.md

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
思考模型在输出中返回 `reasoning_content` 字段,表示思考链内容,即得出最终结论的思考步骤.
66

77
##目前支持思考链的模型
8-
| 模型名称 | 解析器名称 | 默认开启思考链 |
9-
|---------------|-------------|---------|
10-
| baidu/ERNIE-4.5-VL-424B-A47B-Paddle | ernie-45-vl ||
11-
| baidu/ERNIE-4.5-VL-28B-A3B-Paddle | ernie-45-vl ||
8+
| 模型名称 | 解析器名称 | 默认开启思考链 | 工具调用 |
9+
|---------------|-------------|---------|---------|
10+
| baidu/ERNIE-4.5-VL-424B-A47B-Paddle | ernie-45-vl |||
11+
| baidu/ERNIE-4.5-VL-28B-A3B-Paddle | ernie-45-vl |||
12+
| baidu/ERNIE-4.5-21B-A3B-Thinking | ernie-x1 | ✅不支持关思考 ||
1213

1314
思考模型需要指定解析器,以便于对思考内容进行解析. 通过 `"enable_thinking": false` 参数可以关闭模型思考模式.
1415

@@ -83,3 +84,76 @@ for chunk in chat_response:
8384
print("\n")
8485

8586
```
87+
## 工具调用
88+
如果模型支持工具调用, 可以同时启动模型回复内容的思考链解析 `reasoning_content` 及工具解析 `tool-call-parser`。 工具内容仅从模型回复内容 `content` 中进行解析,而不会影响思考链内容。
89+
例如,
90+
```bash
91+
curl -X POST "http://0.0.0.0:8390/v1/chat/completions" \
92+
-H "Content-Type: application/json" \
93+
-d '{
94+
"messages": [
95+
{
96+
"role": "user",
97+
"content": "北京今天天气怎么样?"
98+
}
99+
],
100+
"tools": [
101+
{
102+
"type": "function",
103+
"function": {
104+
"name": "get_weather",
105+
"description": "Determine weather in my location",
106+
"parameters": {
107+
"type": "object",
108+
"properties": {
109+
"location": {
110+
"type": "string",
111+
"description": "The city and state e.g. San Francisco, CA"
112+
},
113+
"unit": {
114+
"type": "string",
115+
"enum": [
116+
"c",
117+
"f"
118+
]
119+
}
120+
},
121+
"additionalProperties": false,
122+
"required": [
123+
"location",
124+
"unit"
125+
]
126+
},
127+
"strict": true
128+
}
129+
}],
130+
"stream": false
131+
}'
132+
```
133+
返回结果示例如下:
134+
```json
135+
{
136+
"choices": [
137+
{
138+
"index": 0,
139+
"message": {
140+
"role": "assistant",
141+
"content": "",
142+
"reasoning_content": "用户问的是..",
143+
"tool_calls": [
144+
{
145+
"id": "chatcmpl-tool-311b9bda34274722afc654c55c8ce6a0",
146+
"type": "function",
147+
"function": {
148+
"name": "get_weather",
149+
"arguments": "{\"location\": \"北京\", \"unit\": \"c\"}"
150+
}
151+
}
152+
]
153+
},
154+
"finish_reason": "tool_calls"
155+
}
156+
]
157+
}
158+
```
159+
更多工具调用相关的使用参考文档 [Tool Calling](./tool_calling.md)

0 commit comments

Comments
 (0)