From 75fb94ec68b4846fa5a9831c4c724550c1f058b1 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 13 Dec 2023 15:31:07 -0800 Subject: [PATCH] feat: show error message in chat --- src/lib/components/chat/Messages.svelte | 27 ++++++++++++++++++++++++- src/routes/(app)/+page.svelte | 8 ++++++++ src/routes/(app)/c/[id]/+page.svelte | 8 ++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Messages.svelte b/src/lib/components/chat/Messages.svelte index aa7bde72c..ad691bf11 100644 --- a/src/lib/components/chat/Messages.svelte +++ b/src/lib/components/chat/Messages.svelte @@ -655,7 +655,32 @@ {:else}
- {@html marked(message.content.replace('\\\\', '\\\\\\'))} + {#if message?.error === true} +
+ + + + +
+ {message.content} +
+
+ {:else} + {@html marked(message.content.replace('\\\\', '\\\\\\'))} + {/if} {#if message.done}
diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index f6bf0e350..44c923978 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -276,12 +276,20 @@ console.log(error); if ('detail' in error) { toast.error(error.detail); + responseMessage.content = error.detail; } else { toast.error(error.error); + responseMessage.content = error.error; } } else { toast.error(`Uh-oh! There was an issue connecting to Ollama.`); + responseMessage.content = `Uh-oh! There was an issue connecting to Ollama.`; } + + responseMessage.error = true; + responseMessage.content = `Uh-oh! There was an issue connecting to Ollama.`; + responseMessage.done = true; + messages = messages; } stopResponseFlag = false; diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 3eec7a5e9..c2685af59 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -303,12 +303,20 @@ console.log(error); if ('detail' in error) { toast.error(error.detail); + responseMessage.content = error.detail; } else { toast.error(error.error); + responseMessage.content = error.error; } } else { toast.error(`Uh-oh! There was an issue connecting to Ollama.`); + responseMessage.content = `Uh-oh! There was an issue connecting to Ollama.`; } + + responseMessage.error = true; + responseMessage.content = `Uh-oh! There was an issue connecting to Ollama.`; + responseMessage.done = true; + messages = messages; } stopResponseFlag = false;