feat: store model configs in the database

This commit is contained in:
Jun Siang Cheah
2024-05-19 18:46:24 +08:00
parent 1bacd5d93f
commit 4002ead6af
50 changed files with 434 additions and 194 deletions
+11 -7
View File
@@ -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();
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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);