diff --git a/ui/src/api/log.ts b/ui/src/api/log.ts index aba762b1e..57126a3d5 100644 --- a/ui/src/api/log.ts +++ b/ui/src/api/log.ts @@ -173,6 +173,18 @@ const getRecordDetail: ( ) } +const getChatLogClient: ( + application_id: String, + page: pageRequest, + loading?: Ref +) => Promise> = (application_id, page, loading) => { + return get( + `${prefix}/${application_id}/chat/client/${page.current_page}/${page.page_size}`, + null, + loading + ) +} + export default { getChatLog, delChatLog, @@ -181,5 +193,6 @@ export default { getMarkRecord, getRecordDetail, delMarkRecord, - exportChatLog + exportChatLog, + getChatLogClient } diff --git a/ui/src/components/ai-chat/index.vue b/ui/src/components/ai-chat/index.vue index 5349d1fa9..654032e2d 100644 --- a/ui/src/components/ai-chat/index.vue +++ b/ui/src/components/ai-chat/index.vue @@ -73,9 +73,7 @@ -
+
知识来源
@@ -208,8 +206,15 @@ const props = defineProps({ available: { type: Boolean, default: true - } + }, + chatId: { + type: String, + default: '' + } // 历史记录Id }) + +const emit = defineEmits(['refresh']) + const { application } = useStore() const ParagraphSourceDialogRef = ref() @@ -248,6 +253,18 @@ const prologueList = computed(() => { return arr }) +watch( + () => props.chatId, + (val) => { + if (val && val !== 'new') { + chartOpenId.value = val + } else { + chartOpenId.value = '' + } + }, + { deep: true } +) + watch( () => props.data, () => { @@ -266,6 +283,18 @@ watch( } ) +function showSource(row: any) { + if (props.log) { + return true + } else if (row.write_ed) { + if (id || props.data?.show_source) { + return true + } + } else { + return false + } +} + function openParagraph(row: any, id?: string) { ParagraphSourceDialogRef.value.open(row, id) } @@ -484,6 +513,9 @@ function chatMessage(chat?: any, problem?: string, re_chat?: boolean) { } }) .then(() => { + if (props.chatId === 'new') { + emit('refresh', chartOpenId.value) + } return (id || props.data?.show_source) && getSourceDetail(chat) }) .finally(() => { diff --git a/ui/src/stores/modules/log.ts b/ui/src/stores/modules/log.ts index 173fa7eab..194aa91ec 100644 --- a/ui/src/stores/modules/log.ts +++ b/ui/src/stores/modules/log.ts @@ -35,6 +35,18 @@ const useLogStore = defineStore({ reject(error) }) }) + }, + async asyncGetChatLogClient(id: string, page: pageRequest, loading?: Ref) { + return new Promise((resolve, reject) => { + logApi + .getChatLogClient(id, page, loading) + .then((data) => { + resolve(data) + }) + .catch((error) => { + reject(error) + }) + }) } } }) diff --git a/ui/src/views/chat/embed/index.vue b/ui/src/views/chat/embed/index.vue index 63da4701e..f9fe92e21 100644 --- a/ui/src/views/chat/embed/index.vue +++ b/ui/src/views/chat/embed/index.vue @@ -58,11 +58,8 @@ function getChatLog(id: string) { current_page: 1, page_size: 20 } - const param = { - history_day: 183 - } - log.asyncGetChatLog(id, page, param, loading).then((res: any) => { + log.asyncGetChatLogClient(id, page, loading).then((res: any) => { chatLogeData.value = res.data.records }) } diff --git a/ui/src/views/chat/pc/index.vue b/ui/src/views/chat/pc/index.vue index 4daee0f96..4a31a65b5 100644 --- a/ui/src/views/chat/pc/index.vue +++ b/ui/src/views/chat/pc/index.vue @@ -18,7 +18,7 @@ :data="chatLogeData" class="mt-8" v-loading="loading" - :defaultActive="currentId" + :defaultActive="currentChatId" @click="clickListHandle" >