Skip to content

Commit 846db07

Browse files
committed
feat(#1228): 支持在对话中调整模型推理等级
1 parent 2b5467d commit 846db07

17 files changed

Lines changed: 363 additions & 10 deletions

‎messages/de.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,6 +2247,17 @@
22472247
"contextWindowPlaceholder": "Automatisch erkennen (16K Fallback)",
22482248
"tokenLimitParam": "Token-Limit-Parameter",
22492249
"tokenLimitParamDesc": "Verwendet standardmäßig max_completion_tokens. Wähle max_tokens für ältere kompatible APIs.",
2250+
"reasoningEffort": {
2251+
"title": "Reasoning-Aufwand",
2252+
"default": "Standard",
2253+
"none": "Deaktiviert",
2254+
"minimal": "Minimal",
2255+
"low": "Niedrig",
2256+
"medium": "Mittel",
2257+
"high": "Hoch",
2258+
"xhigh": "Sehr hoch",
2259+
"max": "Maximum"
2260+
},
22502261
"advancedParameters": "Erweiterte Parameter",
22512262
"selectConfig": "Wähle eine Modellplattform",
22522263
"models": "Modellliste",

‎messages/en.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,17 @@
22652265
"contextWindowPlaceholder": "Auto detect (16K fallback)",
22662266
"tokenLimitParam": "Token Limit Parameter",
22672267
"tokenLimitParamDesc": "Uses max_completion_tokens by default. Select max_tokens for legacy compatible APIs.",
2268+
"reasoningEffort": {
2269+
"title": "Reasoning Effort",
2270+
"default": "Default",
2271+
"none": "Disabled",
2272+
"minimal": "Minimal",
2273+
"low": "Low",
2274+
"medium": "Medium",
2275+
"high": "High",
2276+
"xhigh": "Extra high",
2277+
"max": "Maximum"
2278+
},
22682279
"advancedParameters": "Advanced Parameters",
22692280
"selectConfig": "Select a model platform",
22702281
"models": "Model List",

‎messages/ja.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,17 @@
21012101
"contextWindowPlaceholder": "自動検出(既定16K)",
21022102
"tokenLimitParam": "トークン制限パラメーター",
21032103
"tokenLimitParamDesc": "既定では max_completion_tokens を使用します。旧式の互換APIでは max_tokens を選択してください。",
2104+
"reasoningEffort": {
2105+
"title": "推論レベル",
2106+
"default": "デフォルト",
2107+
"none": "無効",
2108+
"minimal": "最小",
2109+
"low": "低",
2110+
"medium": "中",
2111+
"high": "高",
2112+
"xhigh": "極高",
2113+
"max": "最大"
2114+
},
21042115
"advancedParameters": "詳細パラメーター",
21052116
"selectConfig": "モデルプラットフォームを選択",
21062117
"models": "モデルリスト",

‎messages/pt-BR.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,17 @@
21262126
"contextWindowPlaceholder": "Detectar automaticamente (16K)",
21272127
"tokenLimitParam": "Parâmetro de limite de tokens",
21282128
"tokenLimitParamDesc": "Usa max_completion_tokens por padrão. Selecione max_tokens para APIs compatíveis legadas.",
2129+
"reasoningEffort": {
2130+
"title": "Nível de raciocínio",
2131+
"default": "Padrão",
2132+
"none": "Desativado",
2133+
"minimal": "Mínimo",
2134+
"low": "Baixo",
2135+
"medium": "Médio",
2136+
"high": "Alto",
2137+
"xhigh": "Extra alto",
2138+
"max": "Máximo"
2139+
},
21292140
"advancedParameters": "Parâmetros avançados",
21302141
"selectConfig": "Selecione uma plataforma de modelos",
21312142
"models": "Lista de modelos",

‎messages/zh-TW.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,17 @@
20532053
"contextWindowPlaceholder": "自動偵測(預設 16K)",
20542054
"tokenLimitParam": "Token 限制參數",
20552055
"tokenLimitParamDesc": "預設使用 max_completion_tokens;舊版相容接口可切換為 max_tokens。",
2056+
"reasoningEffort": {
2057+
"title": "推理等級",
2058+
"default": "預設",
2059+
"none": "關閉",
2060+
"minimal": "最低",
2061+
"low": "低",
2062+
"medium": "中",
2063+
"high": "高",
2064+
"xhigh": "極高",
2065+
"max": "最高"
2066+
},
20562067
"advancedParameters": "進階參數",
20572068
"selectConfig": "請選擇模型平台",
20582069
"models": "模型列表",

‎messages/zh.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,17 @@
22402240
"contextWindowPlaceholder": "自动检测(默认 16K)",
22412241
"tokenLimitParam": "Token 限制参数",
22422242
"tokenLimitParamDesc": "默认使用 max_completion_tokens;旧版兼容接口可切换为 max_tokens。",
2243+
"reasoningEffort": {
2244+
"title": "推理等级",
2245+
"default": "默认",
2246+
"none": "关闭",
2247+
"minimal": "最低",
2248+
"low": "低",
2249+
"medium": "中",
2250+
"high": "高",
2251+
"xhigh": "极高",
2252+
"max": "最高"
2253+
},
22432254
"advancedParameters": "高级参数",
22442255
"selectConfig": "请选择模型平台",
22452256
"models": "模型列表",

‎src/app/core/main/chat/agent-session-context.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isLinkedFolder, type LinkedResource, type MarkdownFile } from '@/lib/fi
55
import type { RuntimeChatAttachment } from '@/lib/chat-attachments'
66
import type { CanvasSelectionContext } from '@/types/canvas'
77
import type { ImageAttachment } from './image-attachments'
8+
import type { ChatReasoningOverride } from '@/lib/ai/chat-reasoning'
89

910
export interface AgentQuoteData {
1011
quote: string
@@ -19,6 +20,7 @@ export interface AgentQuoteData {
1920
}
2021

2122
export interface AgentRequestSnapshot {
23+
reasoningOverride?: ChatReasoningOverride | null
2224
inputValue: string
2325
requestText: string
2426
linkedResource?: LinkedResource | null

‎src/app/core/main/chat/chat-send.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type { AgentApprovalDecision, AgentSteeringPayload } from "@/lib/agent/ty
2222
import { serializeChatAttachments, type RuntimeChatAttachment } from '@/lib/chat-attachments'
2323
import { retainCompletedAgentTraceEvents } from '@/lib/agent/trace-retention'
2424
import { getAISettingsByModelId } from '@/lib/ai/utils'
25+
import { applyChatReasoningOverride } from '@/lib/ai/chat-reasoning'
2526
import type { AiConfig } from '@/app/core/setting/config'
2627
import {
2728
buildChatImageContext,
@@ -147,6 +148,7 @@ export const ChatSend = forwardRef<ChatSendHandle, ChatSendProps>(({
147148
}), [agentSession])
148149

149150
const createRequestSnapshot = (overrideText?: string): AgentRequestSnapshot => ({
151+
reasoningOverride: useChatStore.getState().reasoningOverride,
150152
inputValue: overrideText ?? inputValue,
151153
requestText: (overrideText ?? inputValue).trim() || t('record.chat.input.addAttachment.attachmentOnlyPrompt'),
152154
linkedResource,
@@ -1097,7 +1099,9 @@ ${hasValidRange ? `**仅在用户明确要求修改/改写/补充/插入时才
10971099
agentSession.configure({
10981100
execute: async (request) => {
10991101
const modelId = useSettingStore.getState().primaryModel
1100-
const aiConfig = await getAISettingsByModelId(modelId)
1102+
const aiConfig = applyChatReasoningOverride(
1103+
await getAISettingsByModelId(modelId), modelId, request.reasoningOverride ?? null,
1104+
)
11011105
const modelSnapshot = {
11021106
id: modelId,
11031107
name: aiConfig?.model || modelId,

‎src/app/core/main/chat/chat-tools-popover.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ClipboardMonitor } from "./clipboard-monitor"
1717
import { McpServerList } from "./mcp-button"
1818
import { ModelSelect } from "./model-select"
1919
import { PromptSelect } from "./prompt-select"
20+
import { ReasoningSelect } from "./reasoning-select"
2021

2122
const TOOL_IDS = ['modelSelect', 'promptSelect', 'mcpButton', 'clipboardMonitor'] as const
2223

@@ -42,7 +43,7 @@ export function ChatToolsPopover() {
4243
<div className="flex max-h-96 flex-col overflow-y-auto px-3 py-3">
4344
{TOOL_IDS.map((toolId) => (
4445
<div key={toolId}>
45-
{toolId === 'modelSelect' && <ModelSelect display="panel" />}
46+
{toolId === 'modelSelect' && <><ModelSelect display="panel" /><ReasoningSelect /></>}
4647
{toolId === 'promptSelect' && <PromptSelect display="panel" />}
4748
{toolId === 'mcpButton' && (
4849
<Popover>

‎src/app/core/main/chat/model-selection.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export async function changePrimaryChatModel(input: {
8989
const chatState = useChatStore.getState()
9090
const appliesNextTurn = chatState.loading || chatState.agentState.isRunning
9191

92+
useChatStore.getState().setReasoningOverride(null)
9293
settingState.setPrimaryModel(input.modelId)
9394
const store = await Store.load('store.json')
9495
await store.set('primaryModel', input.modelId)

0 commit comments

Comments
 (0)