mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-30 00:19:35 +00:00
Merge pull request #221 from rarnu/feat/ai-thinking-option
feat: 为AI设置增加了thinking的开关
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
import { ref, watch, shallowRef, computed } from "vue";
|
||||
import type { EditorView as EditorViewType } from "@codemirror/view";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { FolderOpen, Loader2, Settings, Trash2 } from "lucide-vue-next";
|
||||
import { CircleHelp, FolderOpen, Loader2, Settings, Trash2 } from "lucide-vue-next";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
@@ -298,6 +299,9 @@ const aiEditModel = ref(settingsStore.aiConfig.model);
|
||||
const aiEditApiStyle = ref<AiApiStyle>(settingsStore.aiConfig.apiStyle || "completions");
|
||||
const aiEditProxyEnabled = ref(!!settingsStore.aiConfig.proxyEnabled);
|
||||
const aiEditProxyUrl = ref(settingsStore.aiConfig.proxyUrl || "");
|
||||
const aiEditEnableThinking = ref(settingsStore.aiConfig.enableThinking ?? true);
|
||||
|
||||
const aiCompletionsMode = computed(() => aiEditApiStyle.value === "completions");
|
||||
|
||||
const aiTesting = ref(false);
|
||||
const aiTestResult = ref<"" | "success" | "error">("");
|
||||
@@ -311,6 +315,7 @@ function syncAiEditState() {
|
||||
aiEditApiStyle.value = settingsStore.aiConfig.apiStyle || "completions";
|
||||
aiEditProxyEnabled.value = !!settingsStore.aiConfig.proxyEnabled;
|
||||
aiEditProxyUrl.value = settingsStore.aiConfig.proxyUrl || "";
|
||||
aiEditEnableThinking.value = settingsStore.aiConfig.enableThinking ?? true;
|
||||
aiTestResult.value = "";
|
||||
aiTestError.value = "";
|
||||
}
|
||||
@@ -329,7 +334,8 @@ function aiHasChanges(): boolean {
|
||||
aiEditModel.value !== settingsStore.aiConfig.model ||
|
||||
aiEditApiStyle.value !== (settingsStore.aiConfig.apiStyle || "completions") ||
|
||||
aiEditProxyEnabled.value !== !!settingsStore.aiConfig.proxyEnabled ||
|
||||
aiEditProxyUrl.value !== (settingsStore.aiConfig.proxyUrl || "")
|
||||
aiEditProxyUrl.value !== (settingsStore.aiConfig.proxyUrl || "") ||
|
||||
aiEditEnableThinking.value !== (settingsStore.aiConfig.enableThinking ?? true)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -342,6 +348,7 @@ function aiApplySettings() {
|
||||
apiStyle: aiEditApiStyle.value,
|
||||
proxyEnabled: aiEditProxyEnabled.value,
|
||||
proxyUrl: aiEditProxyUrl.value,
|
||||
enableThinking: aiEditEnableThinking.value,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -718,6 +725,29 @@ watch(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 items-center gap-3">
|
||||
<Label class="text-right text-xs">{{ t("ai.enableThinking") }}</Label>
|
||||
<div class="col-span-2 flex items-center gap-2">
|
||||
<label class="flex items-center gap-2 text-xs text-muted-foreground">
|
||||
<input
|
||||
v-model="aiEditEnableThinking"
|
||||
type="checkbox"
|
||||
class="h-4 w-4 shrink-0 accent-primary"
|
||||
:disabled="!aiCompletionsMode"
|
||||
/>
|
||||
{{ aiEditEnableThinking ? t("ai.enableThinkingOn") : t("ai.enableThinkingOff") }}
|
||||
</label>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child>
|
||||
<CircleHelp class="h-3.5 w-3.5 cursor-help text-muted-foreground hover:text-foreground" />
|
||||
</PopoverTrigger>
|
||||
<PopoverContent class="max-w-[320px] text-xs leading-relaxed" side="top" align="start">
|
||||
{{ t("ai.enableThinkingHint") }}
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 items-center gap-3">
|
||||
<Label class="text-right text-xs">{{ t("ai.proxy") }}</Label>
|
||||
<label class="col-span-2 flex items-center gap-2 text-xs text-muted-foreground">
|
||||
|
||||
@@ -481,6 +481,11 @@ export default {
|
||||
proxyUrl: "Proxy URL",
|
||||
settingsHint:
|
||||
"The config is stored in the local app data directory. Requests are sent by the Tauri backend instead of directly from the frontend.",
|
||||
enableThinking: "Thinking",
|
||||
enableThinkingOn: "Enabled",
|
||||
enableThinkingOff: "Disabled",
|
||||
enableThinkingHint:
|
||||
"This option only takes effect on /chat/completions APIs and supported models. When disabled, it can significantly reduce token usage, but the quality of generated results may decrease slightly.",
|
||||
actions: {
|
||||
generate: "Generate SQL",
|
||||
explain: "Explain SQL",
|
||||
|
||||
@@ -471,6 +471,11 @@ export default {
|
||||
proxyEnable: "AI 请求通过代理发送",
|
||||
proxyUrl: "代理地址",
|
||||
settingsHint: "配置会保存在本机应用数据目录中。请求由 Tauri 后端发出,避免在前端直接暴露给模型服务。",
|
||||
enableThinking: "Thinking",
|
||||
enableThinkingOn: "已启用",
|
||||
enableThinkingOff: "已禁用",
|
||||
enableThinkingHint:
|
||||
"此选项仅对 /chat/completions API 且部分支持的模型生效。设为禁用后可大幅节省 token,但生成结果质量可能会略微下降。",
|
||||
actions: {
|
||||
generate: "生成 SQL",
|
||||
explain: "解释 SQL",
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface AiConfig {
|
||||
apiStyle: AiApiStyle;
|
||||
proxyEnabled?: boolean;
|
||||
proxyUrl?: string;
|
||||
enableThinking?: boolean;
|
||||
}
|
||||
|
||||
const defaultConfigs: Record<AiProvider, Omit<AiConfig, "apiKey">> = {
|
||||
|
||||
Reference in New Issue
Block a user