From 2c188a45c8a01f7ad762cdcf6077099dc2977610 Mon Sep 17 00:00:00 2001 From: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Date: Fri, 9 Aug 2024 19:06:08 +0800 Subject: [PATCH] feat(app/log): Add Referenced Content in Application Logs (#7082) --- web/app/components/app/log/list.tsx | 1 + web/app/components/base/chat/chat/type.ts | 30 ++++++++++++++--------- web/models/log.ts | 2 ++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/web/app/components/app/log/list.tsx b/web/app/components/app/log/list.tsx index 00d7ffb0fb..646ae80116 100644 --- a/web/app/components/app/log/list.tsx +++ b/web/app/components/app/log/list.tsx @@ -126,6 +126,7 @@ const getFormattedChatList = (messages: ChatMessage[], conversationId: string, t tokens: item.answer_tokens + item.message_tokens, latency: item.provider_response_latency.toFixed(2), }, + citation: item.metadata?.retriever_resources, annotation: (() => { if (item.annotation_hit_history) { return { diff --git a/web/app/components/base/chat/chat/type.ts b/web/app/components/base/chat/chat/type.ts index d1c2839e09..16ccff4d4d 100644 --- a/web/app/components/base/chat/chat/type.ts +++ b/web/app/components/base/chat/chat/type.ts @@ -13,8 +13,14 @@ export type Feedbacktype = { content?: string | null } -export type FeedbackFunc = (messageId: string, feedback: Feedbacktype) => Promise -export type SubmitAnnotationFunc = (messageId: string, content: string) => Promise +export type FeedbackFunc = ( + messageId: string, + feedback: Feedbacktype +) => Promise +export type SubmitAnnotationFunc = ( + messageId: string, + content: string +) => Promise export type DisplayScene = 'web' | 'console' @@ -91,20 +97,22 @@ export type IChatItem = { input?: any } -export type MessageEnd = { - id: string - metadata: { - retriever_resources?: CitationItem[] - annotation_reply: { +export type Metadata = { + retriever_resources?: CitationItem[] + annotation_reply: { + id: string + account: { id: string - account: { - id: string - name: string - } + name: string } } } +export type MessageEnd = { + id: string + metadata: Metadata +} + export type MessageReplace = { id: string task_id: string diff --git a/web/models/log.ts b/web/models/log.ts index 994da445dc..fbd4674c9b 100644 --- a/web/models/log.ts +++ b/web/models/log.ts @@ -4,6 +4,7 @@ import type { Edge, Node, } from '@/app/components/workflow/types' +import type { Metadata } from '@/app/components/base/chat/chat/type' // Log type contains key:string conversation_id:string created_at:string quesiton:string answer:string export type Conversation = { @@ -102,6 +103,7 @@ export type MessageContent = { from_end_user_id?: string }> message_files: VisionFile[] + metadata: Metadata agent_thoughts: any[] // TODO workflow_run_id: string }