Skip to content

Commit

Permalink
fix: fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fredliang44 committed Dec 23, 2023
1 parent ae0d68c commit 45798f9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
5 changes: 5 additions & 0 deletions app/client/platforms/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}));
}
}
Expand Down
1 change: 1 addition & 0 deletions app/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
22 changes: 20 additions & 2 deletions app/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 11 additions & 1 deletion app/store/update.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -134,6 +143,7 @@ export const useUpdateStore = createPersistStore(
}));

try {
const api = new ClientApi(ModelProvider.GPT);
const usage = await api.llm.usage();

if (usage) {
Expand Down
10 changes: 9 additions & 1 deletion app/utils/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 45798f9

Please sign in to comment.