add function to check model is available

This commit is contained in:
lloydzhou
2024-07-04 15:30:24 +08:00
parent 2803a91673
commit e7b16bfbc0
3 changed files with 21 additions and 23 deletions

View File

@@ -1,3 +1,4 @@
import { DEFAULT_MODELS } from "../constant";
import { LLMModel } from "../client/api";
const customProvider = (modelName: string) => ({
@@ -100,3 +101,8 @@ export function collectModelsWithDefaultModel(
const allModels = Object.values(modelTable);
return allModels;
}
export function isModelAvailableInServer(customModels, modelName) {
const modelTable = collectModelTable(DEFAULT_MODELS, customModels);
return modelTable[modelName ?? ""].available === false;
}