Skip to content

Commit fa55cdc

Browse files
fix: chat issue
1 parent ca6630f commit fa55cdc

File tree

6 files changed

+51
-26
lines changed

6 files changed

+51
-26
lines changed

ui/src/components/ai-chat/component/chat-input-operate/index.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,15 @@
271271
<el-button
272272
text
273273
class="sent-button"
274-
:disabled="isDisabledChat || loading"
274+
:disabled="isDisabledChat || loading || !uploadLoading"
275275
@click="sendChatHandle"
276276
>
277-
<img v-show="isDisabledChat || loading" src="@/assets/icon_send.svg" alt="" />
278-
<SendIcon v-show="!isDisabledChat && !loading" />
277+
<img
278+
v-show="isDisabledChat || loading || uploadLoading"
279+
src="@/assets/icon_send.svg"
280+
alt=""
281+
/>
282+
<SendIcon v-show="!isDisabledChat && !loading && !uploadLoading" />
279283
</el-button>
280284
</template>
281285
</div>
@@ -777,7 +781,7 @@ function sendChatHandle(event?: any) {
777781
if (!event?.ctrlKey && !event?.shiftKey && !event?.altKey && !event?.metaKey) {
778782
// 如果没有按下组合键,则会阻止默认事件
779783
event?.preventDefault()
780-
if (!isDisabledChat.value && !props.loading && !event?.isComposing) {
784+
if (!isDisabledChat.value && !props.loading && !event?.isComposing && !uploadLoading.value) {
781785
if (inputValue.value.trim()) {
782786
autoSendMessage()
783787
}

ui/src/components/ai-chat/component/knowledge-source-component/ParagraphCard.vue

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
shadow="never"
44
:title="index + 1 + '.' + data.title || '-'"
55
class="paragraph-source-card cursor mb-8 paragraph-source-card-height"
6-
:style="{ 'height': data?.document_name?.trim() ? '300px' : '260px' }"
6+
:style="{ height: data?.document_name?.trim() ? '300px' : '260px' }"
77
:class="data.is_active ? '' : 'disabled'"
88
:showIcon="false"
99
>
@@ -26,22 +26,23 @@
2626
>
2727
<el-text class="flex align-center item">
2828
<img :src="getImgUrl(data?.document_name?.trim())" alt="" width="20" class="mr-4" />
29-
30-
<template v-if="meta?.source_url">
31-
<a
32-
:href="getNormalizedUrl(meta?.source_url)"
33-
target="_blank"
34-
class="ellipsis-1 break-all"
35-
:title="data?.document_name?.trim()"
36-
>
37-
{{ data?.document_name?.trim() }}
38-
</a>
39-
</template>
40-
<template v-else>
41-
<span class="ellipsis-1 break-all" :title="data?.document_name?.trim()">
42-
{{ data?.document_name?.trim() }}
43-
</span>
44-
</template>
29+
<div class="ml-8">
30+
<div class="ml-4" v-if="data?.meta?.source_file_id || data?.meta?.source_url">
31+
<a
32+
:href="getFileUrl(data?.meta?.source_file_id) || data?.meta?.source_url"
33+
target="_blank"
34+
class="ellipsis-1"
35+
:title="data?.document_name?.trim()"
36+
>
37+
<span :title="data?.document_name?.trim()">{{ data?.document_name }}</span>
38+
</a>
39+
</div>
40+
<div v-else @click="infoMessage">
41+
<span class="ellipsis-1 break-all" :title="data?.document_name?.trim()">
42+
{{ data?.document_name?.trim() }}
43+
</span>
44+
</div>
45+
</div>
4546
</el-text>
4647
</el-card>
4748
<div class="flex align-center border-t" style="padding: 12px 0 8px">
@@ -54,9 +55,10 @@
5455
</CardBox>
5556
</template>
5657
<script setup lang="ts">
57-
import { getImgUrl, getNormalizedUrl } from '@/utils/common'
58+
import { getImgUrl, getFileUrl } from '@/utils/common'
5859
import { computed } from 'vue'
59-
60+
import { MsgInfo } from '@/utils/message'
61+
import { t } from '@/locales'
6062
const props = defineProps({
6163
data: {
6264
type: Object,
@@ -85,6 +87,9 @@ const parsedMeta = computed(() => {
8587
})
8688
8789
const meta = computed(() => (isMetaObject.value ? props.data.meta : parsedMeta.value))
90+
function infoMessage() {
91+
MsgInfo(t('chat.noDocument'))
92+
}
8893
</script>
8994
<style lang="scss" scoped>
9095
// .paragraph-source-card-height {

ui/src/components/ai-chat/component/knowledge-source-component/index.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
>
3333
<p>{{ item && item?.document_name }}</p>
3434
</div>
35-
<div class="ml-8" v-else>
35+
<div
36+
class="ml-4"
37+
v-else-if="item?.meta?.source_file_id || item?.meta?.source_url"
38+
>
3639
<a
3740
:href="getFileUrl(item?.meta?.source_file_id) || item?.meta?.source_url"
3841
target="_blank"
@@ -42,6 +45,11 @@
4245
<span :title="item?.document_name?.trim()">{{ item?.document_name }}</span>
4346
</a>
4447
</div>
48+
<div v-else @click="infoMessage">
49+
<span class="ellipsis-1 break-all" :title="data?.document_name?.trim()">
50+
{{ data?.document_name?.trim() }}
51+
</span>
52+
</div>
4553
</div>
4654
</div>
4755
</el-card>
@@ -121,6 +129,7 @@ import ParagraphSourceContent from './ParagraphSourceContent.vue'
121129
import { arraySort } from '@/utils/array'
122130
import { getImgUrl, getFileUrl } from '@/utils/common'
123131
import { t } from '@/locales'
132+
import { MsgInfo } from '@/utils/message'
124133
const props = defineProps({
125134
data: {
126135
type: Object,
@@ -157,6 +166,10 @@ const dialogTitle = ref('')
157166
const currentComponent = shallowRef<any>(null)
158167
const currentChatDetail = ref<any>(null)
159168
const dialogType = ref('')
169+
170+
function infoMessage() {
171+
MsgInfo(t('chat.noDocument'))
172+
}
160173
function openParagraph(row: any, id?: string) {
161174
dialogTitle.value = t('chat.KnowledgeSource.title')
162175
const obj = cloneDeep(row)

ui/src/locales/lang/en-US/ai-chat.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default {
1313
userInput: 'User Input',
1414
quote: 'Quote',
1515
download: 'Click to Download',
16+
noDocument: 'Original Document Not Found',
1617
passwordValidator: {
1718
title: 'Enter Password to Access',
1819
errorMessage1: 'Password cannot be empty',

ui/src/locales/lang/zh-CN/ai-chat.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default {
1717
quote: '引用',
1818
download: '点击下载文件',
1919
transcribing: '转文字中',
20+
noDocument: '原文档不存在',
2021
passwordValidator: {
2122
title: '请输入密码打开链接',
2223
errorMessage1: '密码不能为空',
@@ -94,7 +95,7 @@ export default {
9495
referenceParagraph: '引用分段',
9596
consume: '消耗tokens',
9697
consumeTime: '耗时',
97-
noSource: '没有检索到知识来源'
98+
noSource: '没有检索到知识来源',
9899
},
99100
paragraphSource: {
100101
title: '知识库引用',

ui/src/locales/lang/zh-Hant/ai-chat.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default {
1313
userInput: '用戶輸入',
1414
quote: '引用',
1515
download: '點擊下載文件',
16+
noDocument: '原文檔不存在',
1617
passwordValidator: {
1718
title: '請輸入密碼打開連結',
1819
errorMessage1: '密碼不能為空',
@@ -101,7 +102,7 @@ export default {
101102
historyRecord: '歷史記錄',
102103
currentChat: '本次對話',
103104
AiResponse: 'AI 回答',
104-
knowedMessage: '已知資訊'
105+
knowedMessage: '已知資訊',
105106
},
106107
editTitle: '編輯標題',
107108
}

0 commit comments

Comments
 (0)