mirror of
https://github.com/open-webui/open-webui
synced 2025-03-04 03:18:03 +00:00
enh: arena model rate to reveal
This commit is contained in:
parent
6d52f913d2
commit
00e9362c2c
@ -7,6 +7,7 @@ type TextStreamUpdate = {
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
citations?: any;
|
citations?: any;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
selectedModelId?: any;
|
||||||
error?: any;
|
error?: any;
|
||||||
usage?: ResponseUsage;
|
usage?: ResponseUsage;
|
||||||
};
|
};
|
||||||
@ -71,6 +72,11 @@ async function* openAIStreamToIterator(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parsedData.selected_model_id) {
|
||||||
|
yield { done: false, value: '', selectedModelId: parsedData.selected_model_id };
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
yield {
|
yield {
|
||||||
done: false,
|
done: false,
|
||||||
value: parsedData.choices?.[0]?.delta?.content ?? '',
|
value: parsedData.choices?.[0]?.delta?.content ?? '',
|
||||||
|
@ -1591,7 +1591,7 @@
|
|||||||
const textStream = await createOpenAITextStream(res.body, $settings.splitLargeChunks);
|
const textStream = await createOpenAITextStream(res.body, $settings.splitLargeChunks);
|
||||||
|
|
||||||
for await (const update of textStream) {
|
for await (const update of textStream) {
|
||||||
const { value, done, citations, error, usage } = update;
|
const { value, done, citations, selectedModelId, error, usage } = update;
|
||||||
if (error) {
|
if (error) {
|
||||||
await handleOpenAIError(error, null, model, responseMessage);
|
await handleOpenAIError(error, null, model, responseMessage);
|
||||||
break;
|
break;
|
||||||
@ -1611,6 +1611,12 @@
|
|||||||
responseMessage.info = { ...usage, openai: true, usage };
|
responseMessage.info = { ...usage, openai: true, usage };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selectedModelId) {
|
||||||
|
responseMessage.selectedModelId = selectedModelId;
|
||||||
|
responseMessage.arena = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (citations) {
|
if (citations) {
|
||||||
responseMessage.citations = citations;
|
responseMessage.citations = citations;
|
||||||
// Only remove status if it was initially set
|
// Only remove status if it was initially set
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
|
|
||||||
import { createEventDispatcher, onMount, getContext } from 'svelte';
|
import { createEventDispatcher, onMount, getContext } from 'svelte';
|
||||||
import { config } from '$lib/stores';
|
import { config, models } from '$lib/stores';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
@ -39,6 +39,8 @@
|
|||||||
let selectedReason = null;
|
let selectedReason = null;
|
||||||
let comment = '';
|
let comment = '';
|
||||||
|
|
||||||
|
let selectedModel = null;
|
||||||
|
|
||||||
$: if (message?.annotation?.rating === 1) {
|
$: if (message?.annotation?.rating === 1) {
|
||||||
reasons = LIKE_REASONS;
|
reasons = LIKE_REASONS;
|
||||||
} else if (message?.annotation?.rating === -1) {
|
} else if (message?.annotation?.rating === -1) {
|
||||||
@ -48,6 +50,16 @@
|
|||||||
onMount(() => {
|
onMount(() => {
|
||||||
selectedReason = message?.annotation?.reason ?? '';
|
selectedReason = message?.annotation?.reason ?? '';
|
||||||
comment = message?.annotation?.comment ?? '';
|
comment = message?.annotation?.comment ?? '';
|
||||||
|
|
||||||
|
if (message?.arena) {
|
||||||
|
selectedModel = $models.find((m) => m.id === message.selectedModelId);
|
||||||
|
toast.success(
|
||||||
|
$i18n.t('This response was generated by "{{model}}"', {
|
||||||
|
model: selectedModel.name
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
loadReasons();
|
loadReasons();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -69,6 +81,12 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if selectedModel}
|
||||||
|
<div class="text-xs font-medium translate-y-1.5">
|
||||||
|
{$i18n.t('This response was generated by "{{model}}"', { model: selectedModel.name })}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class=" my-2.5 rounded-xl px-4 py-3 border border-gray-50 dark:border-gray-850"
|
class=" my-2.5 rounded-xl px-4 py-3 border border-gray-50 dark:border-gray-850"
|
||||||
id="message-feedback-{message.id}"
|
id="message-feedback-{message.id}"
|
||||||
|
Loading…
Reference in New Issue
Block a user