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';
const i18n = getContext('i18n');
let messageElement: HTMLElement;
const dispatch = createEventDispatcher();
@ -134,8 +133,9 @@
};
const renderLatex = () => {
let chatMessageElements = messageElement.getElementsByClassName('chat-assistant');
// let lastChatMessageElement = chatMessageElements[chatMessageElements.length - 1];
let chatMessageElements = document
.getElementById(`message-${message.id}`)
?.getElementsByClassName('chat-assistant');
for (const element of chatMessageElements) {
auto_render(element, {
@ -323,7 +323,7 @@
</script>
{#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
src={modelfiles[message.model]?.imageUrl ?? `${WEBUI_BASE_URL}/static/favicon.png`}
/>

View file

@ -347,11 +347,20 @@
)
.flat(1);
console.log($settings.options.stop);
// console.log($settings.options.stop.map((str) => str));
const [res, controller] = await generateChatCompletion(localStorage.token, {
model: model,
messages: messagesBody,
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,
keep_alive: $settings.keepAlive ?? undefined,
@ -576,7 +585,12 @@
})
})),
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,
top_p: $settings?.options?.top_p ?? undefined,
num_ctx: $settings?.options?.num_ctx ?? undefined,