feat: store model configs in the database
This commit is contained in:
+11
-7
@@ -226,16 +226,18 @@ export const getModelConfig = async (token: string): Promise<GlobalModelConfig>
|
||||
|
||||
export interface ModelConfig {
|
||||
id: string;
|
||||
name?: string;
|
||||
name: string;
|
||||
source: string;
|
||||
base_model?: string;
|
||||
params: ModelParams;
|
||||
}
|
||||
|
||||
export interface ModelParams {
|
||||
description?: string;
|
||||
vision_capable?: boolean;
|
||||
}
|
||||
|
||||
export interface GlobalModelConfig {
|
||||
ollama: ModelConfig[];
|
||||
litellm: ModelConfig[];
|
||||
openai: ModelConfig[];
|
||||
}
|
||||
export type GlobalModelConfig = ModelConfig[];
|
||||
|
||||
export const updateModelConfig = async (token: string, config: GlobalModelConfig) => {
|
||||
let error = null;
|
||||
@@ -246,7 +248,9 @@ export const updateModelConfig = async (token: string, config: GlobalModelConfig
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify(config)
|
||||
body: JSON.stringify({
|
||||
models: config
|
||||
})
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
|
||||
@@ -34,7 +34,7 @@ export const getLiteLLMModels = async (token: string = '') => {
|
||||
name: model.name ?? model.id,
|
||||
external: true,
|
||||
source: 'LiteLLM',
|
||||
custom_info: model.custom_info ?? {}
|
||||
custom_info: model.custom_info
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
return a.name.localeCompare(b.name);
|
||||
|
||||
@@ -234,7 +234,7 @@ export const getOpenAIModels = async (token: string = '') => {
|
||||
id: model.id,
|
||||
name: model.name ?? model.id,
|
||||
external: true,
|
||||
custom_info: model.custom_info ?? {}
|
||||
custom_info: model.custom_info
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
return a.name.localeCompare(b.name);
|
||||
|
||||
Reference in New Issue
Block a user