update error handling

This commit is contained in:
AceDataCloud committed 2023-12-31 15:27:30 +08:00
1 parent c30ef07d29
commit 6e3a62f8e6
6 files changed
+48 -10

No files matched your search

+1 -1
View File
@@ -155,7 +155,7 @@ export default defineComponent({
border-radius: 10px;
background: none;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.1);
top: 40px;
top: 50px;
.upload {
display: inline-block;
&.disabled {
+34 -5
View File
@@ -9,6 +9,7 @@
</div>
</div>
<answering-mark v-if="message.state === messageState.PENDING" />
<el-alert v-if="errorText && message.role === 'assistant'" :title="errorText" type="error" :closable="false" />
</div>
<div class="operations">
<copy-to-clipboard v-if="!Array.isArray(message.content)" :content="message.content" class="btn-copy" />
@@ -20,10 +21,19 @@
import { defineComponent } from 'vue';
import AnsweringMark from './AnsweringMark.vue';
import copy from 'copy-to-clipboard';
import { ElImage } from 'element-plus';
import { ElAlert } from 'element-plus';
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
import { IChatMessage, IChatMessageState } from '@/operators';
import CopyToClipboard from '../common/CopyToClipboard.vue';
import {
ERROR_CODE_API_ERROR,
ERROR_CODE_BAD_REQUEST,
ERROR_CODE_CONTENT_TOO_LARGE,
ERROR_CODE_TIMEOUT,
ERROR_CODE_TOO_MANY_REQUESTS,
ERROR_CODE_UNKNOWN,
ERROR_CODE_USED_UP
} from '@/constants';
interface IData {
copied: boolean;
messageState: typeof IChatMessageState;
@@ -35,7 +45,7 @@ export default defineComponent({
CopyToClipboard,
AnsweringMark,
MarkdownRenderer,
ElImage
ElAlert
},
props: {
message: {
@@ -51,9 +61,28 @@ export default defineComponent({
};
},
computed: {
// conversationId() {
// return this.$route.params?.id?.toString();
// }
errorText() {
if (!this.message.error || !this.message.error?.code) {
return undefined;
}
switch (this.message.error?.code) {
case ERROR_CODE_USED_UP:
return this.$t('chat.message.errorUsedUp');
case ERROR_CODE_API_ERROR:
return this.$t('chat.message.errorApiError');
case ERROR_CODE_BAD_REQUEST:
return this.$t('chat.message.errorBadRequest');
case ERROR_CODE_TIMEOUT:
return this.$t('chat.message.errorTimeout');
case ERROR_CODE_TOO_MANY_REQUESTS:
return this.$t('chat.message.errorTooManyRequests');
case ERROR_CODE_CONTENT_TOO_LARGE:
return this.$t('chat.message.errorContentTooLarge');
case ERROR_CODE_UNKNOWN:
default:
return this.$t('chat.message.errorUnknown');
}
}
},
methods: {
onCopy() {
+9 -1
View File
@@ -13,7 +13,7 @@
<div
v-for="(conversation, conversationIndex) in conversations"
:key="conversationIndex"
class="conversation"
:class="{ conversation: true, active: conversation.id === conversationId }"
@click="onClick(conversation.id)"
>
<div class="icons">
@@ -84,6 +84,9 @@ export default defineComponent({
props: {},
emits: ['click'],
computed: {
conversationId() {
return this.$route.params?.id?.toString();
},
conversations() {
return this.$store.state.chat.conversations;
},
@@ -156,6 +159,11 @@ export default defineComponent({
color: #666;
cursor: pointer;
&.active,
&:hover {
background-color: #eee;
}
.icons {
width: 30px;
padding-left: 10px;
@@ -19,7 +19,7 @@
</el-tag>
</div>
</div>
<div v-if="!full" class="extra">
<div class="extra">
<p v-if="modelValue?.request?.prompt" class="prompt">
<font-awesome-icon icon="fa-solid fa-magic" class="mr-1" />
{{ modelValue?.request?.prompt }}