fix: fix type errors

This commit is contained in:
Fred Liang
2023-12-24 02:39:06 +08:00
parent ae0d68c27e
commit 45798f993d
5 changed files with 46 additions and 4 deletions

View File

@@ -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) {