diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index 8ea86469..68a0fda7 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -323,6 +323,11 @@ export class ChatGPTApi implements LLMApi { return chatModels.map((m) => ({ name: m.id, available: true, + provider: { + id: "openai", + providerName: "OpenAI", + providerType: "openai", + }, })); } } diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 9a622af3..409af64d 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -584,6 +584,7 @@ export function Settings() { const accessStore = useAccessStore(); const shouldHideBalanceQuery = useMemo(() => { const isOpenAiUrl = accessStore.openaiUrl.includes(OPENAI_BASE_URL); + return ( accessStore.hideBalanceQuery || isOpenAiUrl || diff --git a/app/locales/en.ts b/app/locales/en.ts index f90cffd4..4d437ffd 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -319,6 +319,24 @@ const en: LocaleType = { Title: "Custom Models", SubTitle: "Custom model options, seperated by comma", }, + Google: { + ApiKey: { + Title: "API Key", + SubTitle: + "Bypass password access restrictions using a custom Google AI Studio API Key", + Placeholder: "Google AI Studio API Key", + }, + + Endpoint: { + Title: "Endpoint Address", + SubTitle: "Example:", + }, + + ApiVerion: { + Title: "API Version (gemini api version)", + SubTitle: "Select a specific part version", + }, + }, }, Model: "Model", @@ -443,8 +461,8 @@ const en: LocaleType = { }, Exporter: { Description: { - Title: "Only messages after clearing the context will be displayed" - }, + Title: "Only messages after clearing the context will be displayed", + }, Model: "Model", Messages: "Messages", Topic: "Topic", diff --git a/app/store/update.ts b/app/store/update.ts index 3c88866d..7253caff 100644 --- a/app/store/update.ts +++ b/app/store/update.ts @@ -1,8 +1,16 @@ -import { FETCH_COMMIT_URL, FETCH_TAG_URL, StoreKey } from "../constant"; +import { + FETCH_COMMIT_URL, + FETCH_TAG_URL, + ModelProvider, + StoreKey, +} from "../constant"; import { getClientConfig } from "../config/client"; import { createPersistStore } from "../utils/store"; import ChatGptIcon from "../icons/chatgpt.png"; import Locale from "../locales"; +import { use } from "react"; +import { useAppConfig } from "."; +import { ClientApi } from "../client/api"; const ONE_MINUTE = 60 * 1000; const isApp = !!getClientConfig()?.isApp; @@ -126,6 +134,7 @@ export const useUpdateStore = createPersistStore( }, async updateUsage(force = false) { + // only support openai for now const overOneMinute = Date.now() - get().lastUpdateUsage >= ONE_MINUTE; if (!overOneMinute && !force) return; @@ -134,6 +143,7 @@ export const useUpdateStore = createPersistStore( })); try { + const api = new ClientApi(ModelProvider.GPT); const usage = await api.llm.usage(); if (usage) { diff --git a/app/utils/model.ts b/app/utils/model.ts index 16bcc19c..c4a4833e 100644 --- a/app/utils/model.ts +++ b/app/utils/model.ts @@ -4,7 +4,15 @@ export function collectModelTable( models: readonly LLMModel[], customModels: string, ) { - const modelTable: { [key: string]: LLMModel } = {}; + const modelTable: Record< + string, + { + available: boolean; + name: string; + displayName: string; + provider: LLMModel["provider"]; + } + > = {}; // default models models.forEach(