mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 15:31:05 +08:00
Feat/agent thinking switch (#15446)
### What problem does this PR solve? This PR adds an Agent LLM setting to control thinking mode for official providers that expose a thinking switch. Related to #12842. Closes #15445. Some providers expose thinking controls through provider-specific request fields, but Agent LLM settings did not have a unified option for users to enable or disable thinking mode. This PR adds a `Thinking` selector with: - System default - Enabled - Disabled <img width="452" height="278" alt="8566b0b4-0546-4c8a-913d-f9bbd38319f6" src="https://github.com/user-attachments/assets/25b497f7-1ba0-4bfe-940d-6fe79287d6ab" /> <img width="471" height="971" alt="8a0a6bee-f45f-48d5-bd83-17af260de3db" src="https://github.com/user-attachments/assets/41ad43c1-5087-48f1-bf37-f2ca14c2be2f" /> Initial support is limited to the verified official providers: - Qwen / DashScope: `enable_thinking` - Kimi / Moonshot: `thinking.type` - GLM / ZHIPU-AI: `thinking.type` For LiteLLM-based providers, provider-specific fields are forwarded through `extra_body` before `drop_params` filtering so the request parameters are preserved. ### Type of change - [x] New Feature (non-breaking change which adds functionality) --------- Co-authored-by: jiashi <jiashi19@outlook.com> Co-authored-by: Zhichang Yu <yuzhichang@gmail.com>
This commit is contained in:
@@ -38,6 +38,7 @@ interface LlmSettingFieldItemsProps {
|
||||
| 'presence_penalty'
|
||||
| 'frequency_penalty'
|
||||
| 'max_tokens'
|
||||
| 'thinking'
|
||||
>;
|
||||
showCollapse?: boolean;
|
||||
}
|
||||
@@ -61,6 +62,7 @@ export const LlmSettingFieldSchema = {
|
||||
frequency_penalty: z.coerce.number().optional(),
|
||||
max_tokens: z.number().optional(),
|
||||
parameter: z.string().optional(),
|
||||
thinking: z.enum(['default', 'enabled', 'disabled']).optional(),
|
||||
};
|
||||
|
||||
export const LlmSettingSchema = {
|
||||
@@ -80,6 +82,7 @@ export function LlmSettingFieldItems({
|
||||
'presence_penalty',
|
||||
'frequency_penalty',
|
||||
'max_tokens',
|
||||
'thinking',
|
||||
],
|
||||
llmId,
|
||||
showCollapse = false,
|
||||
@@ -249,6 +252,41 @@ export function LlmSettingFieldItems({
|
||||
}}
|
||||
></SliderInputSwitchFormField>
|
||||
)}
|
||||
{showFields.some((item) => item === 'thinking') && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={getFieldWithPrefix('thinking')}
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex justify-between items-center">
|
||||
<FormLabel className="flex-1" tooltip={t('thinkingTip')}>
|
||||
{t('thinking')}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Select
|
||||
value={field.value ?? 'default'}
|
||||
onValueChange={field.onChange}
|
||||
>
|
||||
<SelectTrigger className="flex-1 !m-0">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="default">
|
||||
{t('thinkingDefault')}
|
||||
</SelectItem>
|
||||
<SelectItem value="enabled">
|
||||
{t('thinkingEnabled')}
|
||||
</SelectItem>
|
||||
<SelectItem value="disabled">
|
||||
{t('thinkingDisabled')}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
</CollapseComponent>
|
||||
</div>
|
||||
|
||||
@@ -1056,6 +1056,12 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s
|
||||
maxTokensTip: `The maximum context size of the model; an invalid or incorrect value will cause an error. Defaults to 512.`,
|
||||
maxTokensInvalidMessage: 'Please enter a valid number for Max tokens.',
|
||||
maxTokensMinMessage: 'Max tokens cannot be less than 0.',
|
||||
thinking: 'Thinking',
|
||||
thinkingDefault: 'System default',
|
||||
thinkingEnabled: 'Enabled',
|
||||
thinkingDisabled: 'Disabled',
|
||||
thinkingTip:
|
||||
'Only controls thinking mode for official Qwen, Kimi, and GLM model providers. System default disables Qwen thinking to avoid long-running tasks.',
|
||||
quote: 'Show quote',
|
||||
quoteTip: 'Whether to display the original text as a reference.',
|
||||
selfRag: 'Self-RAG',
|
||||
|
||||
@@ -506,6 +506,11 @@ export default {
|
||||
maxTokensTip: `模型的最大上下文大小;無效或不正確的值會導致錯誤。預設為 512。`,
|
||||
maxTokensInvalidMessage: '請輸入有效的最大標記數。',
|
||||
maxTokensMinMessage: '最大標記數不能小於 0。',
|
||||
thinking: '思考',
|
||||
thinkingDefault: '系統預設',
|
||||
thinkingEnabled: '開啟',
|
||||
thinkingDisabled: '關閉',
|
||||
thinkingTip: '僅控制官方模型提供商中的 Qwen、Kimi 和 GLM 模型思考模式。系統預設會關閉 Qwen 思考,以避免任務長時間執行。',
|
||||
quote: '顯示引文',
|
||||
quoteTip: '是否應該顯示原文出處?',
|
||||
selfRag: 'Self-RAG',
|
||||
|
||||
@@ -957,6 +957,11 @@ NER:使用 spaCy NER 和基于规则的关键词提取来抽取实体和关系
|
||||
maxTokensTip: `模型的最大上下文大小;无效或不正确的值会导致错误。默认值为 512。`,
|
||||
maxTokensInvalidMessage: '请输入有效的最大令牌数。',
|
||||
maxTokensMinMessage: '最大令牌数不能小于 0。',
|
||||
thinking: '思考',
|
||||
thinkingDefault: '系统默认',
|
||||
thinkingEnabled: '开启',
|
||||
thinkingDisabled: '关闭',
|
||||
thinkingTip: '仅控制官方模型提供商中的 Qwen、Kimi 和 GLM 模型思考模式。系统默认会关闭 Qwen 思考,以避免任务长时间运行。',
|
||||
quote: '显示引文',
|
||||
quoteTip: '是否应该显示原文出处?',
|
||||
selfRag: 'Self-RAG',
|
||||
|
||||
Reference in New Issue
Block a user