enh: arena model filter

This commit is contained in:
Timothy J. Baek 2024-10-23 12:40:47 -07:00
parent affb0e5c37
commit 68a47f6a9f
2 changed files with 33 additions and 2 deletions

View File

@ -1102,6 +1102,16 @@ async def generate_chat_completions(form_data: dict, user=Depends(get_verified_u
if model["owned_by"] == "arena":
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
if isinstance(model_ids, list) and model_ids:
selected_model_id = random.choice(model_ids)

View File

@ -37,6 +37,7 @@
let selectedModelId = '';
let modelIds = [];
let filterMode = 'include';
let imageInputElement;
let loading = false;
@ -72,7 +73,8 @@
meta: {
profile_image_url: profileImageUrl,
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;
description = model.meta.description;
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" />
<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}
<div class="flex flex-col">