Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/src/api/types/chat-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface ChatContent {
/** 对话日志中的单条问答记录,仅列出前端使用的字段。 */
export interface ChatLogRecord {
id: string
create_time?: string
/** 提问内容项 */
question: ChatContent
/** 回答内容项列表 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface LogMessageListDeps {

// 从后端 chat_record(reset_chat_record 结构)提取底部信息栏数据
const buildRecordMeta = (raw: ChatLogRecord): ChatRecordMeta => ({
createTime: raw.create_time,
messageTokens: raw.message_tokens || 0,
answerTokens: raw.answer_tokens || 0,
runTime: raw.run_time || 0,
Expand Down
30 changes: 28 additions & 2 deletions ui/src/conversation-panel/components/message-footer/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<script setup lang="ts">
import { computed } from 'vue'
import type { ChatContent } from '@/api/types'
import { copyText } from '@/utils/clipboard'
import { datetimeFormat } from '@/utils/time'
import type { ChatMessage, ChatRecordMeta } from '../../core/types'
import { useExecutionDetailStore } from '../../right-sidebar/execution-detail/index'

Expand All @@ -17,6 +20,19 @@ const EMPTY: ChatRecordMeta = {
const meta = computed<ChatRecordMeta>(() => props.message.record || EMPTY)
const tokens = computed(() => meta.value.messageTokens + meta.value.answerTokens)

// 仅复制回答正文,按展示顺序收集分组内的文本,不包含思考与工具参数。
function collectAnswerText(contents: ChatContent[]): string {
return [...contents]
.sort((left, right) => (left.id || '').localeCompare(right.id || ''))
.flatMap((content) => {
if (content.type === 'GROUP') return collectAnswerText(content.children ?? [])
return content.type === 'TEXT' ? content.content || '' : []
})
.filter(Boolean)
.join('\n\n')
}
const answerText = computed(() => collectAnswerText(props.message.content))

const openExecutionDetail = () => {
detail.showExecutionDetail(meta.value.executionDetails || [])
}
Expand All @@ -25,7 +41,7 @@ const openExecutionDetail = () => {
<style scoped lang="scss"></style>

<template>
<div class="mk-conversation-message-footer gap-3">
<div class="mk-conversation-message-footer space-y-2">
<!-- 助手消息底部信息栏:知识来源 / 执行详情 / Tokens · 耗时 -->
<div class="flex-align-center gap-1">
<el-button v-if="meta.knowledgeCount" text class="-ml-1">
Expand All @@ -43,6 +59,16 @@ const openExecutionDetail = () => {
<span class="text-N600">Tokens {{ tokens }} · 耗时 {{ meta.runTime.toFixed(2) }}s</span>
</template>
</div>
<!-- // TODO 点赞一行 -->
<!-- 其他操作 -->
<div class="flex-align-center gap-2">
<!-- 复制回答正文 -->
<MkTooltip content="复制">
<el-button text class="-ml-1" :disabled="!answerText" @click="copyText(answerText)">
<MkIcon name="icon_copy_outlined" />
</el-button>
</MkTooltip>
<span v-if="meta.createTime" class="text-N600">{{ datetimeFormat(meta.createTime) }}</span>
</div>
<div></div>
</div>
</template>
1 change: 1 addition & 0 deletions ui/src/conversation-panel/components/message-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface MessageListDeps extends Pick<

// 从后端 chat_record(分页项或详情接口,均为 reset_chat_record 结构)提取底部信息栏数据
const buildRecordMeta = (raw?: ChatLogRecord | null): ChatRecordMeta => ({
createTime: raw?.create_time,
messageTokens: raw?.message_tokens || 0,
answerTokens: raw?.answer_tokens || 0,
runTime: raw?.run_time || 0,
Expand Down
1 change: 1 addition & 0 deletions ui/src/conversation-panel/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface Conversation {

// 助手消息底部展示数据(对话结束后 / 历史加载时填充):知识来源数、tokens、耗时、执行详情
export interface ChatRecordMeta {
createTime?: string
messageTokens: number
answerTokens: number
runTime: number
Expand Down
Loading