mirror of
https://github.com/open-webui/open-webui
synced 2025-03-28 19:24:29 +00:00
enh: arena model filter
This commit is contained in:
parent
affb0e5c37
commit
68a47f6a9f
@ -1102,6 +1102,16 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
|
|||||||
|
|
||||||
if model["owned_by"] == "arena":
|
if model["owned_by"] == "arena":
|
||||||
model_ids = model.get("info", {}).get("meta", {}).get("model_ids")
|
model_ids = model.get("info", {}).get("meta", {}).get("model_ids")
|
||||||
|
filter_mode = model.get("info", {}).get("meta", {}).get("filter_mode")
|
||||||
|
if filter_mode == 'exclude':
|
||||||
|
model_ids = [
|
||||||
|
model["id"]
|
||||||
|
for model in await get_all_models()
|
||||||
|
if model.get("owned_by") != "arena"
|
||||||
|
and not model.get("info", {}).get("meta", {}).get("hidden", False)
|
||||||
|
and model["id"] not in model_ids
|
||||||
|
]
|
||||||
|
|
||||||
selected_model_id = None
|
selected_model_id = None
|
||||||
if isinstance(model_ids, list) and model_ids:
|
if isinstance(model_ids, list) and model_ids:
|
||||||
selected_model_id = random.choice(model_ids)
|
selected_model_id = random.choice(model_ids)
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
let selectedModelId = '';
|
let selectedModelId = '';
|
||||||
let modelIds = [];
|
let modelIds = [];
|
||||||
|
let filterMode = 'include';
|
||||||
|
|
||||||
let imageInputElement;
|
let imageInputElement;
|
||||||
let loading = false;
|
let loading = false;
|
||||||
@ -72,7 +73,8 @@
|
|||||||
meta: {
|
meta: {
|
||||||
profile_image_url: profileImageUrl,
|
profile_image_url: profileImageUrl,
|
||||||
description: description || null,
|
description: description || null,
|
||||||
model_ids: modelIds.length > 0 ? modelIds : null
|
model_ids: modelIds.length > 0 ? modelIds : null,
|
||||||
|
filter_mode: modelIds.length > 0 ? (filterMode ? filterMode : null) : null
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -95,6 +97,7 @@
|
|||||||
profileImageUrl = model.meta.profile_image_url;
|
profileImageUrl = model.meta.profile_image_url;
|
||||||
description = model.meta.description;
|
description = model.meta.description;
|
||||||
modelIds = model.meta.model_ids || [];
|
modelIds = model.meta.model_ids || [];
|
||||||
|
filterMode = model.meta?.filter_mode ?? 'include';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -281,7 +284,25 @@
|
|||||||
<hr class=" border-gray-100 dark:border-gray-700/10 my-2.5 w-full" />
|
<hr class=" border-gray-100 dark:border-gray-700/10 my-2.5 w-full" />
|
||||||
|
|
||||||
<div class="flex flex-col w-full">
|
<div class="flex flex-col w-full">
|
||||||
<div class=" mb-1 text-xs text-gray-500">{$i18n.t('Models')}</div>
|
<div class="mb-1 flex justify-between">
|
||||||
|
<div class="text-xs text-gray-500">{$i18n.t('Models')}</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
class=" text-xs text-gray-500"
|
||||||
|
type="button"
|
||||||
|
on:click={() => {
|
||||||
|
filterMode = filterMode === 'include' ? 'exclude' : 'include';
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{#if filterMode === 'include'}
|
||||||
|
{$i18n.t('Include')}
|
||||||
|
{:else}
|
||||||
|
{$i18n.t('Exclude')}
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{#if modelIds.length > 0}
|
{#if modelIds.length > 0}
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
|
Loading…
Reference in New Issue
Block a user