Merge branch 'main' into multimodal

This commit is contained in:
Timothy Jaeryang Baek 2023-12-13 18:43:09 -05:00 committed by GitHub
commit fb1f8b167c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 190 additions and 115 deletions

View file

@ -655,7 +655,32 @@
</div> </div>
{:else} {:else}
<div class="w-full"> <div class="w-full">
{#if message?.error === true}
<div
class="flex mt-2 mb-4 space-x-2 border px-4 py-3 border-red-800 bg-red-800/30 font-medium rounded-lg"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-5 h-5 self-center"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"
/>
</svg>
<div class=" self-center">
{message.content}
</div>
</div>
{:else}
{@html marked(message.content.replace('\\\\', '\\\\\\'))} {@html marked(message.content.replace('\\\\', '\\\\\\'))}
{/if}
{#if message.done} {#if message.done}
<div class=" flex justify-start space-x-1 -mt-2"> <div class=" flex justify-start space-x-1 -mt-2">

View file

@ -158,8 +158,12 @@
}, },
format: $settings.requestFormat ?? undefined format: $settings.requestFormat ?? undefined
}) })
}).catch((err) => {
console.log(err);
return null;
}); });
if (res && res.ok) {
const reader = res.body const reader = res.body
.pipeThrough(new TextDecoderStream()) .pipeThrough(new TextDecoderStream())
.pipeThrough(splitStream('\n')) .pipeThrough(splitStream('\n'))
@ -235,6 +239,27 @@
history: history history: history
}); });
} }
} else {
if (res !== null) {
const error = await res.json();
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; stopResponseFlag = false;
await tick(); await tick();

View file

@ -185,8 +185,12 @@
}, },
format: $settings.requestFormat ?? undefined format: $settings.requestFormat ?? undefined
}) })
}).catch((err) => {
console.log(err);
return null;
}); });
if (res && res.ok) {
const reader = res.body const reader = res.body
.pipeThrough(new TextDecoderStream()) .pipeThrough(new TextDecoderStream())
.pipeThrough(splitStream('\n')) .pipeThrough(splitStream('\n'))
@ -262,6 +266,27 @@
history: history history: history
}); });
} }
} else {
if (res !== null) {
const error = await res.json();
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; stopResponseFlag = false;
await tick(); await tick();