Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
fd31b5f8
Commit
fd31b5f8
authored
May 26, 2024
by
Jun Siang Cheah
Browse files
refac: error message separate from content
parent
37302519
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
28 deletions
+28
-28
src/lib/components/chat/Chat.svelte
src/lib/components/chat/Chat.svelte
+6
-7
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+22
-21
No files found.
src/lib/components/chat/Chat.svelte
View file @
fd31b5f8
...
@@ -681,8 +681,7 @@
...
@@ -681,8 +681,7 @@
if (responseMessage.content == '') {
if (responseMessage.content == '') {
responseMessage.error = true;
responseMessage.error = true;
responseMessage.content =
responseMessage.errorContent = 'Oops! No text generated from Ollama, Please try again.';
'Oops! No text generated from Ollama, Please try again.';
}
}
responseMessage.context = data.context ?? null;
responseMessage.context = data.context ?? null;
...
@@ -754,22 +753,22 @@
...
@@ -754,22 +753,22 @@
console.log(error);
console.log(error);
if ('detail' in error) {
if ('detail' in error) {
toast.error(error.detail);
toast.error(error.detail);
responseMessage.
c
ontent = error.detail;
responseMessage.
errorC
ontent = error.detail;
} else {
} else {
toast.error(error.error);
toast.error(error.error);
responseMessage.
c
ontent = error.error;
responseMessage.
errorC
ontent = error.error;
}
}
} else {
} else {
toast.error(
toast.error(
$i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, { provider: 'Ollama' })
$i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, { provider: 'Ollama' })
);
);
responseMessage.
c
ontent = $i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, {
responseMessage.
errorC
ontent = $i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, {
provider: 'Ollama'
provider: 'Ollama'
});
});
}
}
responseMessage.error = true;
responseMessage.error = true;
responseMessage.
c
ontent = $i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, {
responseMessage.
errorC
ontent = $i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, {
provider: 'Ollama'
provider: 'Ollama'
});
});
responseMessage.done = true;
responseMessage.done = true;
...
@@ -1036,7 +1035,7 @@
...
@@ -1036,7 +1035,7 @@
}
}
responseMessage.error = true;
responseMessage.error = true;
responseMessage.
c
ontent =
responseMessage.
errorC
ontent =
$i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, {
$i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, {
provider: model.name ?? model.id
provider: model.name ?? model.id
}) +
}) +
...
...
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
fd31b5f8
...
@@ -451,7 +451,27 @@
...
@@ -451,7 +451,27 @@
</div>
</div>
{:else}
{:else}
<div class="w-full">
<div class="w-full">
{#if message?.error === true}
{#if message.content === '' && !message.error}
<Skeleton />
{:else if !message.error || message.errorContent}
{#each tokens as token, tokenIdx}
{#if token.type === 'code'}
<CodeBlock
id={`${message.id}-${tokenIdx}`}
lang={token?.lang ?? ''}
code={revertSanitizedResponseContent(token?.text ?? '')}
/>
{:else}
{@html marked.parse(token.raw, {
...defaults,
gfm: true,
breaks: true,
renderer
})}
{/if}
{/each}
{/if}
{#if message.error === true}
<div
<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"
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"
>
>
...
@@ -471,28 +491,9 @@
...
@@ -471,28 +491,9 @@
</svg>
</svg>
<div class=" self-center">
<div class=" self-center">
{message.content}
{
message.errorContent ??
message.content}
</div>
</div>
</div>
</div>
{:else if message.content === ''}
<Skeleton />
{:else}
{#each tokens as token, tokenIdx}
{#if token.type === 'code'}
<CodeBlock
id={`${message.id}-${tokenIdx}`}
lang={token?.lang ?? ''}
code={revertSanitizedResponseContent(token?.text ?? '')}
/>
{:else}
{@html marked.parse(token.raw, {
...defaults,
gfm: true,
breaks: true,
renderer
})}
{/if}
{/each}
{/if}
{/if}
{#if message.citations}
{#if message.citations}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment