feat: #2330 disable /list/models

This commit is contained in:
Yidadaa
2023-07-10 23:19:43 +08:00
parent c00a63e4c3
commit 15e063e1b5
4 changed files with 20 additions and 25 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: {