Merge branch 'Yidadaa:main' into main

This commit is contained in:
Hk-Gosuto
2023-07-11 13:02:58 +08:00
committed by GitHub
26 changed files with 357 additions and 235 deletions

View File

@@ -1,5 +1,6 @@
import {
DEFAULT_API_HOST,
DEFAULT_MODELS,
OpenaiPath,
REQUEST_TIMEOUT_MS,
} from "@/app/constant";
@@ -23,6 +24,8 @@ export interface OpenAIListModelResponse {
}
export class ChatGPTApi implements LLMApi {
private disableListModels = true;
path(path: string): string {
let openaiUrl = useAccessStore.getState().openaiUrl;
if (openaiUrl.length === 0) {
@@ -246,6 +249,10 @@ export class ChatGPTApi implements LLMApi {
}
async models(): Promise<LLMModel[]> {
if (this.disableListModels) {
return DEFAULT_MODELS.slice();
}
const res = await fetch(this.path(OpenaiPath.ListModelPath), {
method: "GET",
headers: {