mirror of
https://github.com/open-webui/open-webui
synced 2025-04-24 00:06:11 +00:00
refac: error message separate from content
This commit is contained in:
parent
3730251958
commit
fd31b5f8d6
@ -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 @@
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
if ('detail' in error) {
|
if ('detail' in error) {
|
||||||
toast.error(error.detail);
|
toast.error(error.detail);
|
||||||
responseMessage.content = error.detail;
|
responseMessage.errorContent = error.detail;
|
||||||
} else {
|
} else {
|
||||||
toast.error(error.error);
|
toast.error(error.error);
|
||||||
responseMessage.content = error.error;
|
responseMessage.errorContent = 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.content = $i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, {
|
responseMessage.errorContent = $i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, {
|
||||||
provider: 'Ollama'
|
provider: 'Ollama'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
responseMessage.error = true;
|
responseMessage.error = true;
|
||||||
responseMessage.content = $i18n.t(`Uh-oh! There was an issue connecting to {{provider}}.`, {
|
responseMessage.errorContent = $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 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
responseMessage.error = true;
|
responseMessage.error = true;
|
||||||
responseMessage.content =
|
responseMessage.errorContent =
|
||||||
$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
|
||||||
}) +
|
}) +
|
||||||
|
@ -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 @@
|
|||||||
</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}
|
||||||
|
Loading…
Reference in New Issue
Block a user