diff --git a/src/composables/useLlmProviderDirectory.ts b/src/composables/useLlmProviderDirectory.ts index 3236d29e..43c8bb10 100644 --- a/src/composables/useLlmProviderDirectory.ts +++ b/src/composables/useLlmProviderDirectory.ts @@ -83,6 +83,7 @@ interface UseLlmProviderDirectoryOptions { apiKey: Ref baseUrl: Ref baseUrlPreset?: Ref + useProxy?: Ref userAgent?: Ref model: Ref maxContextTokens?: Ref @@ -254,6 +255,7 @@ export function useLlmProviderDirectory(options: UseLlmProviderDirectoryOptions) api_key: normalizeValue(options.apiKey.value) || undefined, base_url: normalizeValue(options.baseUrl.value) || undefined, base_url_preset: normalizeValue(options.baseUrlPreset?.value) || undefined, + use_proxy: options.useProxy?.value, user_agent: normalizeValue(options.userAgent?.value) || undefined, force_refresh: forceRefresh, }, diff --git a/src/composables/useSetupWizard.ts b/src/composables/useSetupWizard.ts index 62e73481..9ac4a6b7 100644 --- a/src/composables/useSetupWizard.ts +++ b/src/composables/useSetupWizard.ts @@ -61,6 +61,7 @@ export interface WizardData { supportAudioOutput: boolean apiKey: string baseUrl: string + useProxy: boolean baseUrlPreset: string maxContextTokens: number userAgent: string @@ -248,6 +249,7 @@ const wizardData = ref({ supportAudioOutput: false, apiKey: '', baseUrl: 'https://api.deepseek.com', + useProxy: true, baseUrlPreset: '', maxContextTokens: 64, userAgent: '', @@ -1446,6 +1448,7 @@ export function useSetupWizard() { LLM_SUPPORT_AUDIO_OUTPUT: wizardData.value.agent.supportAudioOutput, LLM_API_KEY: wizardData.value.agent.apiKey, LLM_BASE_URL: wizardData.value.agent.baseUrl || null, + LLM_USE_PROXY: wizardData.value.agent.useProxy, LLM_BASE_URL_PRESET: wizardData.value.agent.baseUrlPreset || null, LLM_MAX_CONTEXT_TOKENS: wizardData.value.agent.maxContextTokens, LLM_USER_AGENT: wizardData.value.agent.userAgent || null, @@ -1560,6 +1563,7 @@ export function useSetupWizard() { wizardData.value.agent.supportAudioOutput = Boolean(result.data.LLM_SUPPORT_AUDIO_OUTPUT) wizardData.value.agent.apiKey = result.data.LLM_API_KEY || '' wizardData.value.agent.baseUrl = result.data.LLM_BASE_URL || '' + wizardData.value.agent.useProxy = result.data.LLM_USE_PROXY ?? true wizardData.value.agent.baseUrlPreset = result.data.LLM_BASE_URL_PRESET || '' wizardData.value.agent.maxContextTokens = result.data.LLM_MAX_CONTEXT_TOKENS || 64 wizardData.value.agent.userAgent = result.data.LLM_USER_AGENT || '' diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index 2debbaa6..fef6e025 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -1456,6 +1456,9 @@ export default { llmApiKeyPlaceholder: 'Please enter API key', llmBaseUrl: 'LLM Base URL', llmBaseUrlHint: 'Base URL for LLM API, used for custom API endpoints', + llmUseProxy: 'Use System Proxy', + llmUseProxyHint: + 'When enabled, Agent connections to the current LLM provider use the system proxy from advanced settings.', llmUserAgent: 'User-Agent', llmUserAgentHint: 'User-Agent sent to OpenAI-compatible APIs. Leave empty to use the SDK default.', llmProviderAuth: 'Provider Authorization', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index a714d2ee..e5656215 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -1448,6 +1448,8 @@ export default { llmApiKeyPlaceholder: '请输入API密钥', llmBaseUrl: 'LLM基础URL', llmBaseUrlHint: 'LLM API的基础URL地址,用于自定义API端点', + llmUseProxy: '使用系统代理', + llmUseProxyHint: '启用后,Agent 连接当前 LLM 提供商时会应用高级设置中的系统代理', llmUserAgent: 'User-Agent', llmUserAgentHint: 'OpenAI 兼容接口请求使用的 User-Agent,留空则使用 SDK 默认值', llmProviderAuth: '提供商授权', diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts index d26c42ea..0b17c914 100644 --- a/src/locales/zh-TW.ts +++ b/src/locales/zh-TW.ts @@ -1449,6 +1449,8 @@ export default { llmApiKeyPlaceholder: '請輸入API密鑰', llmBaseUrl: 'LLM基礎URL', llmBaseUrlHint: 'LLM API的基礎URL地址,用於自定義API端點', + llmUseProxy: '使用系統代理', + llmUseProxyHint: '啟用後,Agent 連接目前 LLM 提供商時會套用進階設定中的系統代理', llmUserAgent: 'User-Agent', llmUserAgentHint: 'OpenAI 兼容接口請求使用的 User-Agent,留空則使用 SDK 預設值', llmProviderAuth: '提供商授權', diff --git a/src/views/setting/AccountSettingSystem.vue b/src/views/setting/AccountSettingSystem.vue index 5a72c1fb..d662033e 100644 --- a/src/views/setting/AccountSettingSystem.vue +++ b/src/views/setting/AccountSettingSystem.vue @@ -57,6 +57,7 @@ const SystemSettings = ref({ LLM_SUPPORT_AUDIO_OUTPUT: false, LLM_API_KEY: null, LLM_BASE_URL: 'https://api.deepseek.com', + LLM_USE_PROXY: true, LLM_BASE_URL_PRESET: null, LLM_MAX_CONTEXT_TOKENS: 64, LLM_USER_AGENT: null, @@ -214,6 +215,7 @@ type LlmSettingsSnapshot = { LLM_THINKING_LEVEL: string LLM_API_KEY: string LLM_BASE_URL: string + LLM_USE_PROXY: boolean LLM_BASE_URL_PRESET: string LLM_USER_AGENT: string } @@ -249,6 +251,13 @@ const llmBaseUrlPresetRef = computed({ }, }) +const llmUseProxyRef = computed({ + get: () => Boolean(SystemSettings.value.Basic.LLM_USE_PROXY), + set: value => { + SystemSettings.value.Basic.LLM_USE_PROXY = Boolean(value) + }, +}) + const llmUserAgentRef = computed({ get: () => String(SystemSettings.value.Basic.LLM_USER_AGENT ?? ''), set: value => { @@ -301,6 +310,7 @@ const { apiKey: llmApiKeyRef, baseUrl: llmBaseUrlRef, baseUrlPreset: llmBaseUrlPresetRef, + useProxy: llmUseProxyRef, userAgent: llmUserAgentRef, model: llmModelRef, maxContextTokens: llmMaxContextRef, @@ -362,6 +372,7 @@ function buildLlmSnapshot(): LlmSettingsSnapshot { LLM_THINKING_LEVEL: String(SystemSettings.value.Basic.LLM_THINKING_LEVEL ?? 'off'), LLM_API_KEY: String(SystemSettings.value.Basic.LLM_API_KEY ?? ''), LLM_BASE_URL: String(SystemSettings.value.Basic.LLM_BASE_URL ?? ''), + LLM_USE_PROXY: Boolean(SystemSettings.value.Basic.LLM_USE_PROXY), LLM_BASE_URL_PRESET: String(SystemSettings.value.Basic.LLM_BASE_URL_PRESET ?? ''), LLM_USER_AGENT: String(SystemSettings.value.Basic.LLM_USER_AGENT ?? ''), } @@ -379,6 +390,7 @@ function buildLlmTestPayload(snapshot: LlmSettingsSnapshot) { thinking_level: snapshot.LLM_THINKING_LEVEL.trim(), api_key: snapshot.LLM_API_KEY.trim(), base_url: snapshot.LLM_BASE_URL.trim(), + use_proxy: snapshot.LLM_USE_PROXY, base_url_preset: snapshot.LLM_BASE_URL_PRESET.trim(), user_agent: snapshot.LLM_USER_AGENT.trim(), } @@ -1206,6 +1218,14 @@ watch(currentLlmSnapshotKey, (snapshotKey, previousSnapshotKey) => { + + + wizardData.value.agent.useProxy, + set: value => { + wizardData.value.agent.useProxy = Boolean(value) + }, +}) + const userAgentRef = computed({ get: () => wizardData.value.agent.userAgent, set: value => { @@ -99,6 +106,7 @@ const { apiKey: apiKeyRef, baseUrl: baseUrlRef, baseUrlPreset: baseUrlPresetRef, + useProxy: useProxyRef, userAgent: userAgentRef, model: modelRef, maxContextTokens: maxContextTokensRef, @@ -341,6 +349,16 @@ onMounted(async () => { + + + +