Created
November 7, 2023 17:06
-
-
Save DanielViglione/91471fc96fdf6b7c770c4a12d20d33bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions 18 | |
src/lib/components/chat/ChatWindow.svelte | |
@@ -20,6 +20,7 @@ | |
import RetryBtn from "../RetryBtn.svelte"; | |
export let messages: Message[] = []; | |
export let temperature: number = 0.9; | |
export let loading = false; | |
export let pending = false; | |
export let shared = false; | |
@@ -105,6 +106,23 @@ | |
/> | |
{/if} | |
</div> | |
<div class="flex flex-col space-y-2 p-2 pb-8 w-80 self-start"> | |
<input type="range" class="w-full" min="0" max="1" step="0.1" value="0.9" on:change={(ev) => {temperature = ev.target?.value;}}/> | |
<ul class="flex justify-between w-full px-[10px]"> | |
<li class="flex justify-center relative"><span class="absolute">0.1</span></li> | |
<li class="flex justify-center relative"><span class="absolute">0.2</span></li> | |
<li class="flex justify-center relative"><span class="absolute">0.3</span></li> | |
<li class="flex justify-center relative"><span class="absolute">0.4</span></li> | |
<li class="flex justify-center relative"><span class="absolute">0.5</span></li> | |
<li class="flex justify-center relative"><span class="absolute">0.6</span></li> | |
<li class="flex justify-center relative"><span class="absolute">0.7</span></li> | |
<li class="flex justify-center relative"><span class="absolute">0.8</span></li> | |
<li class="flex justify-center relative"><span class="absolute">0.9</span></li> | |
<li class="flex justify-center relative"><span class="absolute">1</span></li> | |
</ul> | |
</div> | |
<form | |
on:submit|preventDefault={handleSubmit} | |
class="relative flex w-full max-w-4xl flex-1 items-center rounded-xl border bg-gray-100 focus-within:border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:focus-within:border-gray-500 | |
4 changes: 4 additions & 0 deletions 4 | |
src/routes/conversation/[id]/+page.svelte | |
@@ -32,6 +32,8 @@ | |
let loading = false; | |
let pending = false; | |
let temperature: number; | |
async function convFromShared() { | |
try { | |
loading = true; | |
@@ -94,6 +96,7 @@ | |
inputs: message, | |
id: messageId, | |
response_id: responseId, | |
temperature: temperature, | |
is_retry: isRetry, | |
web_search: $webSearchParameters.useSearch, | |
}), | |
@@ -283,6 +286,7 @@ | |
shared={data.shared} | |
preprompt={data.preprompt} | |
bind:webSearchMessages | |
bind:temperature | |
on:message={onMessage} | |
on:retry={onRetry} | |
on:vote={(event) => voteMessage(event.detail.score, event.detail.id)} | |
3 changes: 3 additions & 0 deletions 3 | |
src/routes/conversation/[id]/+server.ts | |
@@ -96,13 +96,15 @@ export async function POST({ request, fetch, locals, params, getClientAddress }) | |
const { | |
inputs: newPrompt, | |
response_id: responseId, | |
temperature: temperature, | |
id: messageId, | |
is_retry, | |
web_search: webSearch, | |
} = z | |
.object({ | |
inputs: z.string().trim().min(1), | |
id: z.optional(z.string().uuid()), | |
temperature: z.optional(z.number()), | |
response_id: z.optional(z.string().uuid()), | |
is_retry: z.optional(z.boolean()), | |
web_search: z.optional(z.boolean()), | |
@@ -266,6 +268,7 @@ export async function POST({ request, fetch, locals, params, getClientAddress }) | |
{ | |
parameters: { | |
...models.find((m) => m.id === conv.model)?.parameters, | |
...{ temperature }, | |
return_full_text: false, | |
}, | |
model: randomEndpoint.url, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment