diff --git a/app/client/platforms/anthropic.ts b/app/client/platforms/anthropic.ts index 7826838a6..49934c923 100644 --- a/app/client/platforms/anthropic.ts +++ b/app/client/platforms/anthropic.ts @@ -7,8 +7,6 @@ import { usePluginStore, ChatMessageTool, } from "@/app/store"; -import { getClientConfig } from "@/app/config/client"; -import { DEFAULT_API_HOST } from "@/app/constant"; import { getMessageTextContent, isVisionModel } from "@/app/utils"; import { preProcessImageContent, stream } from "@/app/utils/chat"; import { cloudflareAIGatewayUrl } from "@/app/utils/cloudflare"; @@ -386,11 +384,7 @@ export class ClaudeApi implements LLMApi { // if endpoint is empty, use default endpoint if (baseUrl.trim().length === 0) { - const isApp = !!getClientConfig()?.isApp; - - baseUrl = isApp - ? DEFAULT_API_HOST + "/api/proxy/anthropic" - : ApiPath.Anthropic; + baseUrl = ApiPath.Anthropic; } if (!baseUrl.startsWith("http") && !baseUrl.startsWith("/api")) { diff --git a/app/client/platforms/google.ts b/app/client/platforms/google.ts index 0ffe1d3aa..d0a573201 100644 --- a/app/client/platforms/google.ts +++ b/app/client/platforms/google.ts @@ -8,8 +8,6 @@ import { SpeechOptions, } from "../api"; import { useAccessStore, useAppConfig, useChatStore } from "@/app/store"; -import { getClientConfig } from "@/app/config/client"; -import { DEFAULT_API_HOST } from "@/app/constant"; import Locale from "../../locales"; import { EventStreamContentType, @@ -33,9 +31,8 @@ export class GeminiProApi implements LLMApi { baseUrl = accessStore.googleUrl; } - const isApp = !!getClientConfig()?.isApp; if (baseUrl.length === 0) { - baseUrl = isApp ? DEFAULT_API_HOST + `/api/proxy/google` : ApiPath.Google; + baseUrl = ApiPath.Google; } if (baseUrl.endsWith("/")) { baseUrl = baseUrl.slice(0, baseUrl.length - 1); diff --git a/app/client/platforms/iflytek.ts b/app/client/platforms/iflytek.ts index a8e0e08b8..88b02b2cd 100644 --- a/app/client/platforms/iflytek.ts +++ b/app/client/platforms/iflytek.ts @@ -1,10 +1,5 @@ "use client"; -import { - ApiPath, - DEFAULT_API_HOST, - Iflytek, - REQUEST_TIMEOUT_MS, -} from "@/app/constant"; +import { ApiPath, Iflytek, REQUEST_TIMEOUT_MS } from "@/app/constant"; import { useAccessStore, useAppConfig, useChatStore } from "@/app/store"; import { @@ -20,7 +15,6 @@ import { fetchEventSource, } from "@fortaine/fetch-event-source"; import { prettyObject } from "@/app/utils/format"; -import { getClientConfig } from "@/app/config/client"; import { getMessageTextContent, fetch } from "@/app/utils"; import { RequestPayload } from "./openai"; @@ -38,9 +32,7 @@ export class SparkApi implements LLMApi { } if (baseUrl.length === 0) { - const isApp = !!getClientConfig()?.isApp; - const apiPath = ApiPath.Iflytek; - baseUrl = isApp ? DEFAULT_API_HOST + "/proxy" + apiPath : apiPath; + baseUrl = ApiPath.Iflytek; } if (baseUrl.endsWith("/")) { diff --git a/app/client/platforms/moonshot.ts b/app/client/platforms/moonshot.ts index 6b1979745..595c2bef2 100644 --- a/app/client/platforms/moonshot.ts +++ b/app/client/platforms/moonshot.ts @@ -1,11 +1,6 @@ "use client"; // azure and openai, using same models. so using same LLMApi. -import { - ApiPath, - DEFAULT_API_HOST, - Moonshot, - REQUEST_TIMEOUT_MS, -} from "@/app/constant"; +import { ApiPath, Moonshot, REQUEST_TIMEOUT_MS } from "@/app/constant"; import { useAccessStore, useAppConfig, @@ -21,7 +16,6 @@ import { LLMModel, SpeechOptions, } from "../api"; -import { getClientConfig } from "@/app/config/client"; import { getMessageTextContent } from "@/app/utils"; import { RequestPayload } from "./openai"; @@ -38,9 +32,8 @@ export class MoonshotApi implements LLMApi { } if (baseUrl.length === 0) { - const isApp = !!getClientConfig()?.isApp; const apiPath = ApiPath.Moonshot; - baseUrl = isApp ? DEFAULT_API_HOST + "/proxy" + apiPath : apiPath; + baseUrl = apiPath; } if (baseUrl.endsWith("/")) { diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index 0a8d6203a..b3950a147 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -2,7 +2,6 @@ // azure and openai, using same models. so using same LLMApi. import { ApiPath, - DEFAULT_API_HOST, DEFAULT_MODELS, OpenaiPath, Azure, @@ -36,7 +35,6 @@ import { SpeechOptions, } from "../api"; import Locale from "../../locales"; -import { getClientConfig } from "@/app/config/client"; import { getMessageTextContent, isVisionModel, @@ -96,9 +94,7 @@ export class ChatGPTApi implements LLMApi { } if (baseUrl.length === 0) { - const isApp = !!getClientConfig()?.isApp; - const apiPath = isAzure ? ApiPath.Azure : ApiPath.OpenAI; - baseUrl = isApp ? DEFAULT_API_HOST + "/proxy" + apiPath : apiPath; + baseUrl = isAzure ? ApiPath.Azure : ApiPath.OpenAI; } if (baseUrl.endsWith("/")) { diff --git a/app/client/platforms/tencent.ts b/app/client/platforms/tencent.ts index 4e28b65c8..e522aa135 100644 --- a/app/client/platforms/tencent.ts +++ b/app/client/platforms/tencent.ts @@ -1,5 +1,5 @@ "use client"; -import { ApiPath, DEFAULT_API_HOST, REQUEST_TIMEOUT_MS } from "@/app/constant"; +import { ApiPath, REQUEST_TIMEOUT_MS } from "@/app/constant"; import { useAccessStore, useAppConfig, useChatStore } from "@/app/store"; import { @@ -16,7 +16,6 @@ import { fetchEventSource, } from "@fortaine/fetch-event-source"; import { prettyObject } from "@/app/utils/format"; -import { getClientConfig } from "@/app/config/client"; import { getMessageTextContent, isVisionModel, fetch } from "@/app/utils"; import mapKeys from "lodash-es/mapKeys"; import mapValues from "lodash-es/mapValues"; @@ -69,10 +68,7 @@ export class HunyuanApi implements LLMApi { } if (baseUrl.length === 0) { - const isApp = !!getClientConfig()?.isApp; - baseUrl = isApp - ? DEFAULT_API_HOST + "/api/proxy/tencent" - : ApiPath.Tencent; + baseUrl = ApiPath.Tencent; } if (baseUrl.endsWith("/")) { diff --git a/app/constant.ts b/app/constant.ts index acb744cad..52138d84d 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -11,7 +11,6 @@ export const RUNTIME_CONFIG_DOM = "danger-runtime-config"; export const STABILITY_BASE_URL = "https://api.stability.ai"; -export const DEFAULT_API_HOST = "https://api.nextchat.dev"; export const OPENAI_BASE_URL = "https://api.openai.com"; export const ANTHROPIC_BASE_URL = "https://api.anthropic.com"; diff --git a/app/store/access.ts b/app/store/access.ts index d74cb9d02..e3bc43c5d 100644 --- a/app/store/access.ts +++ b/app/store/access.ts @@ -1,6 +1,5 @@ import { ApiPath, - DEFAULT_API_HOST, GoogleSafetySettingsThreshold, ServiceProvider, StoreKey, @@ -15,46 +14,6 @@ let fetchState = 0; // 0 not fetch, 1 fetching, 2 done const isApp = getClientConfig()?.buildMode === "export"; -const DEFAULT_OPENAI_URL = isApp - ? DEFAULT_API_HOST + "/api/proxy/openai" - : ApiPath.OpenAI; - -const DEFAULT_GOOGLE_URL = isApp - ? DEFAULT_API_HOST + "/api/proxy/google" - : ApiPath.Google; - -const DEFAULT_ANTHROPIC_URL = isApp - ? DEFAULT_API_HOST + "/api/proxy/anthropic" - : ApiPath.Anthropic; - -const DEFAULT_BAIDU_URL = isApp - ? DEFAULT_API_HOST + "/api/proxy/baidu" - : ApiPath.Baidu; - -const DEFAULT_BYTEDANCE_URL = isApp - ? DEFAULT_API_HOST + "/api/proxy/bytedance" - : ApiPath.ByteDance; - -const DEFAULT_ALIBABA_URL = isApp - ? DEFAULT_API_HOST + "/api/proxy/alibaba" - : ApiPath.Alibaba; - -const DEFAULT_TENCENT_URL = isApp - ? DEFAULT_API_HOST + "/api/proxy/tencent" - : ApiPath.Tencent; - -const DEFAULT_MOONSHOT_URL = isApp - ? DEFAULT_API_HOST + "/api/proxy/moonshot" - : ApiPath.Moonshot; - -const DEFAULT_STABILITY_URL = isApp - ? DEFAULT_API_HOST + "/api/proxy/stability" - : ApiPath.Stability; - -const DEFAULT_IFLYTEK_URL = isApp - ? DEFAULT_API_HOST + "/api/proxy/iflytek" - : ApiPath.Iflytek; - const DEFAULT_ACCESS_STATE = { accessCode: "", useCustomConfig: false, @@ -62,7 +21,7 @@ const DEFAULT_ACCESS_STATE = { provider: ServiceProvider.OpenAI, // openai - openaiUrl: DEFAULT_OPENAI_URL, + openaiUrl: ApiPath.OpenAI as string, openaiApiKey: "", // azure @@ -71,44 +30,44 @@ const DEFAULT_ACCESS_STATE = { azureApiVersion: "2023-08-01-preview", // google ai studio - googleUrl: DEFAULT_GOOGLE_URL, + googleUrl: ApiPath.Google as string, googleApiKey: "", googleApiVersion: "v1", googleSafetySettings: GoogleSafetySettingsThreshold.BLOCK_ONLY_HIGH, // anthropic - anthropicUrl: DEFAULT_ANTHROPIC_URL, + anthropicUrl: ApiPath.Anthropic as string, anthropicApiKey: "", anthropicApiVersion: "2023-06-01", // baidu - baiduUrl: DEFAULT_BAIDU_URL, + baiduUrl: ApiPath.Baidu as string, baiduApiKey: "", baiduSecretKey: "", // bytedance - bytedanceUrl: DEFAULT_BYTEDANCE_URL, + bytedanceUrl: ApiPath.ByteDance as string, bytedanceApiKey: "", // alibaba - alibabaUrl: DEFAULT_ALIBABA_URL, + alibabaUrl: ApiPath.Alibaba as string, alibabaApiKey: "", // moonshot - moonshotUrl: DEFAULT_MOONSHOT_URL, + moonshotUrl: ApiPath.Moonshot as string, moonshotApiKey: "", //stability - stabilityUrl: DEFAULT_STABILITY_URL, + stabilityUrl: ApiPath.Stability as string, stabilityApiKey: "", // tencent - tencentUrl: DEFAULT_TENCENT_URL, + tencentUrl: ApiPath.Tencent as string, tencentSecretKey: "", tencentSecretId: "", // iflytek - iflytekUrl: DEFAULT_IFLYTEK_URL, + iflytekUrl: ApiPath.Iflytek as string, iflytekApiKey: "", iflytekApiSecret: "", diff --git a/app/store/sync.ts b/app/store/sync.ts index 9db60d5f4..8477c1e4b 100644 --- a/app/store/sync.ts +++ b/app/store/sync.ts @@ -12,7 +12,6 @@ import { downloadAs, readFromFile } from "../utils"; import { showToast } from "../components/ui-lib"; import Locale from "../locales"; import { createSyncClient, ProviderType } from "../utils/cloud"; -import { corsPath } from "../utils/cors"; export interface WebDavConfig { server: string; @@ -26,7 +25,7 @@ export type SyncStore = GetStoreState; const DEFAULT_SYNC_STATE = { provider: ProviderType.WebDAV, useProxy: true, - proxyUrl: corsPath(ApiPath.Cors), + proxyUrl: ApiPath.Cors as string, webdav: { endpoint: "", diff --git a/app/utils/cors.ts b/app/utils/cors.ts deleted file mode 100644 index f5e5ce6f0..000000000 --- a/app/utils/cors.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { getClientConfig } from "../config/client"; -import { DEFAULT_API_HOST } from "../constant"; - -export function corsPath(path: string) { - const baseUrl = getClientConfig()?.isApp ? `${DEFAULT_API_HOST}` : ""; - - if (baseUrl === "" && path === "") { - return ""; - } - if (!path.startsWith("/")) { - path = "/" + path; - } - - if (!path.endsWith("/")) { - path += "/"; - } - - return `${baseUrl}${path}`; -} diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 4d3d121a6..687d8d022 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2033,7 +2033,6 @@ dependencies = [ "tauri-build", "tauri-plugin-http", "tauri-plugin-log", - "wry 0.43.1 (git+https://github.com/lloydzhou/wry?branch=webkitgtk-data_manager-directory)", ] [[package]]