From e71ef4215594e12bef58d1603a596d2c24f9ff6f Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 27 Apr 2024 20:46:34 -0400 Subject: [PATCH] fix: stop seq backslash issue --- src/routes/(app)/+page.svelte | 3 --- src/routes/(app)/c/[id]/+page.svelte | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index bcaad8c5b..f745fcbe6 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -347,9 +347,6 @@ ) .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, diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index cbf0595a9..33578681f 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -365,7 +365,13 @@ 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, @@ -588,7 +594,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,