diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index db6d6159b..91b29738d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -36,7 +36,14 @@ const submitPrompt = async () => { console.log('submitPrompt'); - if (selectedModel !== '') { + if (selectedModel === '') { + toast.error('Model not selected'); + } else if ( + Object.keys(chatHistory).length != 0 && + chatHistory[Object.keys(chatHistory).length - 1].done != true + ) { + console.log('wait'); + } else { console.log(prompt); let user_prompt = prompt; @@ -53,6 +60,12 @@ window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' }); }, 50); + chatHistory[Object.keys(chatHistory).length] = { + role: 'assistant', + content: '' + }; + window.scrollTo({ top: document.body.scrollHeight }); + const res = await fetch(`${ENDPOINT}/api/generate`, { method: 'POST', headers: { @@ -65,12 +78,6 @@ }) }); - chatHistory[Object.keys(chatHistory).length] = { - role: 'assistant', - content: '' - }; - window.scrollTo({ top: document.body.scrollHeight }); - const reader = res.body .pipeThrough(new TextDecoderStream()) .pipeThrough(splitStream('\n')) @@ -110,8 +117,6 @@ } window.scrollTo({ top: document.body.scrollHeight }); - } else { - toast.error('Model not selected'); } }; @@ -196,7 +201,7 @@ {#each Object.keys(chatHistory) as messageIdx}
-
+
-
- {@html marked.parse(chatHistory[messageIdx].content)} - -
+ {#if chatHistory[messageIdx].role != 'user' && chatHistory[messageIdx].content == ''} +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+ {:else} +
+ {@html marked.parse(chatHistory[messageIdx].content)} +
+ {/if} +
@@ -269,23 +296,27 @@ />
- + + + {:else} +
...
+ {/if}
@@ -303,3 +334,18 @@ -->
+ +