mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac: switch to meta and params, remove source
This commit is contained in:
@@ -227,16 +227,18 @@ export const getModelConfig = async (token: string): Promise<GlobalModelConfig>
|
||||
export interface ModelConfig {
|
||||
id: string;
|
||||
name: string;
|
||||
source: string;
|
||||
base_model?: string;
|
||||
meta: ModelMeta;
|
||||
base_model_id?: string;
|
||||
params: ModelParams;
|
||||
}
|
||||
|
||||
export interface ModelParams {
|
||||
export interface ModelMeta {
|
||||
description?: string;
|
||||
vision_capable?: boolean;
|
||||
}
|
||||
|
||||
export interface ModelParams {}
|
||||
|
||||
export type GlobalModelConfig = ModelConfig[];
|
||||
|
||||
export const updateModelConfig = async (token: string, config: GlobalModelConfig) => {
|
||||
|
||||
@@ -343,7 +343,7 @@
|
||||
const hasImages = messages.some((message) =>
|
||||
message.files?.some((file) => file.type === 'image')
|
||||
);
|
||||
if (hasImages && !(model.custom_info?.params.vision_capable ?? true)) {
|
||||
if (hasImages && !(model.custom_info?.meta.vision_capable ?? true)) {
|
||||
toast.error(
|
||||
$i18n.t('Model {{modelName}} is not vision capable', {
|
||||
modelName: model.custom_info?.name ?? model.name ?? model.id
|
||||
|
||||
@@ -359,7 +359,7 @@
|
||||
if (!model) {
|
||||
continue;
|
||||
}
|
||||
if (model.custom_info?.params.vision_capable ?? true) {
|
||||
if (model.custom_info?.meta.vision_capable ?? true) {
|
||||
visionCapableCount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,10 +307,10 @@
|
||||
</div>
|
||||
</Tooltip>
|
||||
{/if}
|
||||
{#if item.info?.custom_info?.params.description}
|
||||
{#if item.info?.custom_info?.meta.description}
|
||||
<Tooltip
|
||||
content={`${sanitizeResponseContent(
|
||||
item.info.custom_info?.params.description
|
||||
item.info.custom_info?.meta.description
|
||||
).replaceAll('\n', '<br>')}`}
|
||||
>
|
||||
<div class="">
|
||||
|
||||
@@ -80,8 +80,8 @@
|
||||
const model = $models.find((m) => m.id === selectedModelId);
|
||||
if (model) {
|
||||
modelName = model.custom_info?.name ?? model.name;
|
||||
modelDescription = model.custom_info?.params.description ?? '';
|
||||
modelIsVisionCapable = model.custom_info?.params.vision_capable ?? false;
|
||||
modelDescription = model.custom_info?.meta.description ?? '';
|
||||
modelIsVisionCapable = model.custom_info?.meta.vision_capable ?? false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -518,18 +518,16 @@
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
const modelSource =
|
||||
'details' in model ? 'ollama' : model.source === 'LiteLLM' ? 'litellm' : 'openai';
|
||||
// Remove any existing config
|
||||
modelConfig = modelConfig.filter(
|
||||
(m) => !(m.id === selectedModelId && m.source === modelSource)
|
||||
(m) => !(m.id === selectedModelId)
|
||||
);
|
||||
// Add new config
|
||||
modelConfig.push({
|
||||
id: selectedModelId,
|
||||
name: modelName,
|
||||
source: modelSource,
|
||||
params: {
|
||||
params: {},
|
||||
meta: {
|
||||
description: modelDescription,
|
||||
vision_capable: modelIsVisionCapable
|
||||
}
|
||||
@@ -549,10 +547,8 @@
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
const modelSource =
|
||||
'details' in model ? 'ollama' : model.source === 'LiteLLM' ? 'litellm' : 'openai';
|
||||
modelConfig = modelConfig.filter(
|
||||
(m) => !(m.id === selectedModelId && m.source === modelSource)
|
||||
(m) => !(m.id === selectedModelId)
|
||||
);
|
||||
await updateModelConfig(localStorage.token, modelConfig);
|
||||
toast.success(
|
||||
|
||||
Reference in New Issue
Block a user