fix: stop seq backslash issue

#1747
This commit is contained in:
Timothy J. Baek 2024-04-27 20:45:09 -04:00
parent ebeaa24e9d
commit 7f3daa19cd
2 changed files with 20 additions and 6 deletions

View file

@ -11,7 +11,6 @@
import { onMount, tick, getContext } from 'svelte'; import { onMount, tick, getContext } from 'svelte';
const i18n = getContext('i18n'); const i18n = getContext('i18n');
let messageElement: HTMLElement;
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -134,8 +133,9 @@
}; };
const renderLatex = () => { const renderLatex = () => {
let chatMessageElements = messageElement.getElementsByClassName('chat-assistant'); let chatMessageElements = document
// let lastChatMessageElement = chatMessageElements[chatMessageElements.length - 1]; .getElementById(`message-${message.id}`)
?.getElementsByClassName('chat-assistant');
for (const element of chatMessageElements) { for (const element of chatMessageElements) {
auto_render(element, { auto_render(element, {
@ -323,7 +323,7 @@
</script> </script>
{#key message.id} {#key message.id}
<div class=" flex w-full message-{message.id}" bind:this={messageElement}> <div class=" flex w-full message-{message.id}" id="message-{message.id}">
<ProfileImage <ProfileImage
src={modelfiles[message.model]?.imageUrl ?? `${WEBUI_BASE_URL}/static/favicon.png`} src={modelfiles[message.model]?.imageUrl ?? `${WEBUI_BASE_URL}/static/favicon.png`}
/> />

View file

@ -347,11 +347,20 @@
) )
.flat(1); .flat(1);
console.log($settings.options.stop);
// console.log($settings.options.stop.map((str) => str));
const [res, controller] = await generateChatCompletion(localStorage.token, { const [res, controller] = await generateChatCompletion(localStorage.token, {
model: model, model: model,
messages: messagesBody, messages: messagesBody,
options: { options: {
...($settings.options ?? {}) ...($settings.options ?? {}),
stop:
$settings?.options?.stop ?? undefined
? $settings.options.stop.map((str) =>
decodeURIComponent(JSON.parse('"' + str.replace(/\"/g, '\\"') + '"'))
)
: undefined
}, },
format: $settings.requestFormat ?? undefined, format: $settings.requestFormat ?? undefined,
keep_alive: $settings.keepAlive ?? undefined, keep_alive: $settings.keepAlive ?? undefined,
@ -576,7 +585,12 @@
}) })
})), })),
seed: $settings?.options?.seed ?? undefined, seed: $settings?.options?.seed ?? undefined,
stop: $settings?.options?.stop ?? undefined, stop:
$settings?.options?.stop ?? undefined
? $settings?.options?.stop.map((str) =>
decodeURIComponent(JSON.parse('"' + str.replace(/\"/g, '\\"') + '"'))
)
: undefined,
temperature: $settings?.options?.temperature ?? undefined, temperature: $settings?.options?.temperature ?? undefined,
top_p: $settings?.options?.top_p ?? undefined, top_p: $settings?.options?.top_p ?? undefined,
num_ctx: $settings?.options?.num_ctx ?? undefined, num_ctx: $settings?.options?.num_ctx ?? undefined,