Skip to content

Commit c526a97

Browse files
committed
enable reason_effort for some models that support this argument
1 parent 6f6d429 commit c526a97

4 files changed

Lines changed: 52 additions & 2 deletions

File tree

src/renderer/src/components/LLMResult.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<div class="w-full h-full overflow-hidden p-2 bg-surface-0 rounded-md flex flex-col gap-2">
33
<div class=" flex-none w-full h-10 flex items-center gap-2 justify-end">
44
<div class="flex-auto text-sm text-gray-500 transition duration-500 ease-in-out p-1">{{ progress }}</div>
5+
<div class="text-sm text-primary-700 ">
6+
{{ llmName }}
7+
</div>
58
<Button icon="iconify lucide-lab--copy-type w-6 h-6" outlined @click="copyAsText" />
69
<Button icon="iconify lucide-lab--copy-text w-6 h-6" outlined @click="copyAsHtml" />
710
<Button icon="iconify lucide-lab--copy-code w-6 h-6" outlined @click="copyAsCode" />
@@ -53,6 +56,10 @@ const props = defineProps({
5356
type: String,
5457
default: '',
5558
},
59+
llmName: {
60+
type: String,
61+
default: '',
62+
},
5663
});
5764
5865
const htmlNode = useTemplateRef('htmlNode');

src/renderer/src/pages/EditLlm.vue

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,38 @@
1010
<Password v-model="llm.apiKey" inputClass="w-full" placeholder="API密钥" toggleMask />
1111
<div class="font-bold">模型</div>
1212
<InputText v-model="llm.model" class="w-full" placeholder="模型名称" />
13+
<div>思考力度</div>
14+
<div class="flex gap-2">
15+
<RadioButton v-model="llm.reasoningEffort" name="none" value="" class="" />
16+
<label for="none" class="">默认</label>
17+
<RadioButton v-model="llm.reasoningEffort" name="none" value="none" class="" />
18+
<label for="none" class="">无</label>
19+
<RadioButton v-model="llm.reasoningEffort" name="low" value="low" class="" />
20+
<label for="low" class="">低</label>
21+
<RadioButton v-model="llm.reasoningEffort" name="medium" value="medium" class="" />
22+
<label for="medium" class="">中</label>
23+
<RadioButton v-model="llm.reasoningEffort" name="high" value="high" class="" />
24+
<label for="high" class="">高</label>
25+
<RadioButton v-model="llm.reasoningEffort" name="auto" value="auto" class="" />
26+
<label for="auto" class="">自动</label>
27+
</div>
1328
<div>视觉模型</div>
1429
<InputText v-model="llm.visionModel" class="w-full" placeholder="视觉模型名称, 主模型不支持视觉的备选" />
30+
<div>思考力度</div>
31+
<div class="flex gap-2">
32+
<RadioButton v-model="llm.visionReasoningEffort" name="none" value="" class="" />
33+
<label for="none" class="">默认</label>
34+
<RadioButton v-model="llm.visionReasoningEffort" name="none" value="none" class="" />
35+
<label for="none" class="">无</label>
36+
<RadioButton v-model="llm.visionReasoningEffort" name="low" value="low" class="" />
37+
<label for="low" class="">低</label>
38+
<RadioButton v-model="llm.visionReasoningEffort" name="medium" value="medium" class="" />
39+
<label for="medium" class="">中</label>
40+
<RadioButton v-model="llm.visionReasoningEffort" name="high" value="high" class="" />
41+
<label for="high" class="">高</label>
42+
<RadioButton v-model="llm.visionReasoningEffort" name="auto" value="auto" class="" />
43+
<label for="auto" class="">自动</label>
44+
</div>
1545
<div>服务商</div>
1646
<InputText v-model="llm.provider" class="w-full" placeholder="服务商" />
1747
</div>

src/renderer/src/pages/Main.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<InputText v-model="currentText" class="w-full flex-auto" placeholder="可以输入些什么然后回车,但更便捷的是在你当前软件中选中然后按下 Ctrl+Q"
66
@keydown.enter="onEditSend" />
77
</div>
8-
<LLMResult :text="llmResult" :format="currentTool?.responseFormat" :progress="llmProgress" class="flex-auto">
8+
<LLMResult :text="llmResult" :format="currentTool?.responseFormat" :progress="llmProgress" :llm-name="llmName"
9+
class="flex-auto">
910
</LLMResult>
1011

1112
</div>
@@ -29,6 +30,7 @@ const currentText = ref('');
2930
const currentImage = ref('');
3031
const llmResult = ref('');
3132
const llmProgress = ref('');
33+
const llmName = ref('');
3234
const settings = useSettings();
3335
const tools = useTools();
3436
@@ -146,6 +148,7 @@ async function requestLLM(userPrompt: string, imageUrl: string = ''): Promise<st
146148
});
147149
148150
const model = imageUrl && settings.llm.visionModel ? settings.llm.visionModel : settings.llm.model
151+
const modelReasoningEffort = imageUrl && settings.llm.visionReasoningEffort ? settings.llm.visionReasoningEffort : settings.llm.reasoningEffort
149152
const responseFormat = `请以 ${currentTool.value?.responseFormat || "markdown"} 格式返回结果`
150153
151154
const request: ChatCompletionCreateParamsStreaming = {
@@ -158,6 +161,11 @@ async function requestLLM(userPrompt: string, imageUrl: string = ''): Promise<st
158161
response_format: currentTool.value?.responseFormat === 'json' ? { 'type': 'json_object' } : undefined,
159162
}
160163
164+
if (modelReasoningEffort) {
165+
//@ts-ignore
166+
request.reasoning_effort = modelReasoningEffort;
167+
}
168+
161169
if (imageUrl) {
162170
request.messages.push({
163171
role: 'user',
@@ -218,6 +226,9 @@ async function llmToolCall(llmClient: OpenAI, request: OpenAI.Chat.Completions.C
218226
const tooCalls: Record<number, OpenAI.Chat.Completions.ChatCompletionChunk.Choice.Delta.ToolCall> = {}
219227
220228
for await (const chunk of stream) {
229+
if (chunk.model?.length > 0 && llmName.value !== chunk.model) {
230+
llmName.value = chunk.model;
231+
}
221232
for (const choice of chunk.choices) {
222233
if (choice.delta.content) {
223234
llmProgress.value = `正在生成...`

src/renderer/src/services/models.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type AiTool = {
1717
}
1818

1919
export function aiToolEqual(a: AiTool, b: AiTool): boolean {
20-
return a.name === b.name && a.systemPrompt === b.systemPrompt && a.userPrompt === b.userPrompt && a.mcp === b.mcp && a.responseFormat === b.responseFormat && a.postAction === b.postAction;
20+
return a.name === b.name && a.systemPrompt === b.systemPrompt && a.userPrompt === b.userPrompt && a.mcp === b.mcp && a.responseFormat === b.responseFormat && a.postAction === b.postAction ;
2121
}
2222

2323
export const DEFAULT_TOOLS: AiTool[] = [
@@ -71,8 +71,10 @@ export type LLMConfig = {
7171
baseUrl: string;
7272
/// The LLM model
7373
model: string;
74+
reasoningEffort?: 'low' | 'medium' | 'high' | 'none' | 'auto' | '';
7475
/// The vision model
7576
visionModel?: string;
77+
visionReasoningEffort?: 'low' | 'medium' | 'high' | 'none' | 'auto' | '';
7678
/// The LLM provider
7779
provider?: string;
7880
}

0 commit comments

Comments
 (0)