Aiproxy (#3649)
* model config * feat: model config ui * perf: rename variable * feat: custom request url * perf: model buffer * perf: init model * feat: json model config * auto login * fix: ts * update packages * package * fix: dockerfile
This commit is contained in:
@@ -1,51 +1,54 @@
|
||||
import { SystemModelItemType } from './type';
|
||||
|
||||
export const getFirstLLMModel = () => {
|
||||
return Array.from(global.llmModelMap.values())[0];
|
||||
};
|
||||
export const getLLMModel = (model?: string) => {
|
||||
return (
|
||||
global.llmModels.find((item) => item.model === model || item.name === model) ??
|
||||
global.llmModels[0]
|
||||
);
|
||||
if (!model) return getFirstLLMModel();
|
||||
return global.llmModelMap.get(model) || getFirstLLMModel();
|
||||
};
|
||||
|
||||
export const getDatasetModel = (model?: string) => {
|
||||
return (
|
||||
global.llmModels
|
||||
Array.from(global.llmModelMap.values())
|
||||
?.filter((item) => item.datasetProcess)
|
||||
?.find((item) => item.model === model || item.name === model) ?? global.llmModels[0]
|
||||
?.find((item) => item.model === model || item.name === model) ?? getFirstLLMModel()
|
||||
);
|
||||
};
|
||||
|
||||
export const getVectorModel = (model?: string) => {
|
||||
return (
|
||||
global.vectorModels.find((item) => item.model === model || item.name === model) ||
|
||||
global.vectorModels[0]
|
||||
);
|
||||
export const getFirstEmbeddingModel = () => Array.from(global.embeddingModelMap.values())[0];
|
||||
export const getEmbeddingModel = (model?: string) => {
|
||||
if (!model) return getFirstEmbeddingModel();
|
||||
return global.embeddingModelMap.get(model) || getFirstEmbeddingModel();
|
||||
};
|
||||
|
||||
export function getAudioSpeechModel(model?: string) {
|
||||
return (
|
||||
global.audioSpeechModels.find((item) => item.model === model || item.name === model) ||
|
||||
global.audioSpeechModels[0]
|
||||
);
|
||||
export const getFirstTTSModel = () => Array.from(global.ttsModelMap.values())[0];
|
||||
export function getTTSModel(model?: string) {
|
||||
if (!model) return getFirstTTSModel();
|
||||
return global.ttsModelMap.get(model) || getFirstTTSModel();
|
||||
}
|
||||
|
||||
export function getWhisperModel(model?: string) {
|
||||
return global.whisperModel;
|
||||
export const getFirstSTTModel = () => Array.from(global.sttModelMap.values())[0];
|
||||
export function getSTTModel(model?: string) {
|
||||
if (!model) return getFirstSTTModel();
|
||||
return global.sttModelMap.get(model) || getFirstSTTModel();
|
||||
}
|
||||
|
||||
export const getFirstReRankModel = () => Array.from(global.reRankModelMap.values())[0];
|
||||
export function getReRankModel(model?: string) {
|
||||
return global.reRankModels.find((item) => item.model === model);
|
||||
if (!model) return getFirstReRankModel();
|
||||
return global.reRankModelMap.get(model) || getFirstReRankModel();
|
||||
}
|
||||
|
||||
export enum ModelTypeEnum {
|
||||
llm = 'llm',
|
||||
vector = 'vector',
|
||||
audioSpeech = 'audioSpeech',
|
||||
whisper = 'whisper',
|
||||
rerank = 'rerank'
|
||||
}
|
||||
export const getModelMap = {
|
||||
[ModelTypeEnum.llm]: getLLMModel,
|
||||
[ModelTypeEnum.vector]: getVectorModel,
|
||||
[ModelTypeEnum.audioSpeech]: getAudioSpeechModel,
|
||||
[ModelTypeEnum.whisper]: getWhisperModel,
|
||||
[ModelTypeEnum.rerank]: getReRankModel
|
||||
export const findAIModel = (model: string): SystemModelItemType | undefined => {
|
||||
return (
|
||||
global.llmModelMap.get(model) ||
|
||||
global.embeddingModelMap.get(model) ||
|
||||
global.ttsModelMap.get(model) ||
|
||||
global.sttModelMap.get(model) ||
|
||||
global.reRankModelMap.get(model)
|
||||
);
|
||||
};
|
||||
export const findModelFromAlldata = (model: string) => {
|
||||
return global.systemModelList.find((item) => item.model === model);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user