mirror of
https://github.com/open-webui/open-webui
synced 2025-03-09 14:10:46 +00:00
feat: scaffolding for logit_bias
This commit is contained in:
parent
82189066e8
commit
4a2a12fd21
@ -61,6 +61,7 @@ def apply_model_params_to_body_openai(params: dict, form_data: dict) -> dict:
|
||||
"reasoning_effort": str,
|
||||
"seed": lambda x: x,
|
||||
"stop": lambda x: [bytes(s, "utf-8").decode("unicode_escape") for s in x],
|
||||
"logit_bias": lambda x: x,
|
||||
}
|
||||
return apply_model_params_to_body(params, form_data, mappings)
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
stop: null,
|
||||
temperature: null,
|
||||
reasoning_effort: null,
|
||||
logit_bias: null,
|
||||
frequency_penalty: null,
|
||||
repeat_last_n: null,
|
||||
mirostat: null,
|
||||
@ -298,6 +299,49 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class=" py-0.5 w-full justify-between">
|
||||
<Tooltip
|
||||
content={$i18n.t(
|
||||
'Boosting or penalizing specific tokens for constrained responses. Bias values will be normalized to be between -100 and 100 (inclusive). (Default: none)'
|
||||
)}
|
||||
placement="top-start"
|
||||
className="inline-tooltip"
|
||||
>
|
||||
<div class="flex w-full justify-between">
|
||||
<div class=" self-center text-xs font-medium">
|
||||
{$i18n.t('Logit Bias')}
|
||||
</div>
|
||||
<button
|
||||
class="p-1 px-3 text-xs flex rounded-sm transition shrink-0 outline-hidden"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
params.logit_bias = (params?.logit_bias ?? null) === null ? '' : null;
|
||||
}}
|
||||
>
|
||||
{#if (params?.logit_bias ?? null) === null}
|
||||
<span class="ml-2 self-center"> {$i18n.t('Default')} </span>
|
||||
{:else}
|
||||
<span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</Tooltip>
|
||||
|
||||
{#if (params?.logit_bias ?? null) !== null}
|
||||
<div class="flex mt-0.5 space-x-2">
|
||||
<div class=" flex-1">
|
||||
<input
|
||||
class="w-full rounded-lg py-2 px-1 text-sm dark:text-gray-300 dark:bg-gray-850 outline-hidden"
|
||||
type="text"
|
||||
placeholder={$i18n.t('Enter logit bias as comma-seperated "token_id:bias_value" pairs')}
|
||||
bind:value={params.logit_bias}
|
||||
autocomplete="off"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class=" py-0.5 w-full justify-between">
|
||||
<Tooltip
|
||||
content={$i18n.t(
|
||||
|
@ -50,6 +50,7 @@
|
||||
seed: null,
|
||||
temperature: null,
|
||||
reasoning_effort: null,
|
||||
logit_bias: null,
|
||||
frequency_penalty: null,
|
||||
presence_penalty: null,
|
||||
repeat_penalty: null,
|
||||
@ -348,6 +349,8 @@
|
||||
temperature: params.temperature !== null ? params.temperature : undefined,
|
||||
reasoning_effort:
|
||||
params.reasoning_effort !== null ? params.reasoning_effort : undefined,
|
||||
logit_bias:
|
||||
params.logit_bias !== null ? params.logit_bias : undefined,
|
||||
frequency_penalty:
|
||||
params.frequency_penalty !== null ? params.frequency_penalty : undefined,
|
||||
presence_penalty: params.frequency_penalty !== null ? params.frequency_penalty : undefined,
|
||||
|
Loading…
Reference in New Issue
Block a user