- {
- isShowPromptLog && !isResponding && (
-
- )
- }
diff --git a/web/app/components/app/chat/type.ts b/web/app/components/app/chat/type.ts
index 3f2e60d376..f49f6d1881 100644
--- a/web/app/components/app/chat/type.ts
+++ b/web/app/components/app/chat/type.ts
@@ -79,9 +79,10 @@ export type IChatItem = {
useCurrentUserAvatar?: boolean
isOpeningStatement?: boolean
suggestedQuestions?: string[]
- log?: { role: string; text: string }[]
+ log?: { role: string; text: string; files?: VisionFile[] }[]
agent_thoughts?: ThoughtItem[]
message_files?: VisionFile[]
+ workflow_run_id?: string
}
export type MessageEnd = {
diff --git a/web/app/components/app/log/list.tsx b/web/app/components/app/log/list.tsx
index 06e95ff562..49ad61fe32 100644
--- a/web/app/components/app/log/list.tsx
+++ b/web/app/components/app/log/list.tsx
@@ -80,7 +80,6 @@ const getFormattedChatList = (messages: ChatMessage[]) => {
id: `question-${item.id}`,
content: item.inputs.query || item.inputs.default_input || item.query, // text generation: item.inputs.query; chat: item.query
isAnswer: false,
- log: item.message as any,
message_files: item.message_files?.filter((file: any) => file.belongs_to === 'user') || [],
})
newChatList.push({
@@ -92,6 +91,15 @@ const getFormattedChatList = (messages: ChatMessage[]) => {
feedbackDisabled: false,
isAnswer: true,
message_files: item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || [],
+ log: [
+ ...item.message,
+ {
+ role: 'assistant',
+ text: item.answer,
+ files: item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || [],
+ },
+ ],
+ workflow_run_id: item.workflow_run_id,
more: {
time: dayjs.unix(item.created_at).format('hh:mm A'),
tokens: item.answer_tokens + item.message_tokens,
@@ -175,7 +183,7 @@ function DetailPanel
{
- if (appDetail?.id && detail.id && appDetail?.mode === 'completion')
+ if (appDetail?.id && detail.id && appDetail?.mode !== 'completion')
fetchData()
}, [appDetail?.id, detail.id, appDetail?.mode])
diff --git a/web/app/components/base/audio-btn/index.tsx b/web/app/components/base/audio-btn/index.tsx
index 1492b859fa..676b85414b 100644
--- a/web/app/components/base/audio-btn/index.tsx
+++ b/web/app/components/base/audio-btn/index.tsx
@@ -115,10 +115,9 @@ const AudioBtn = ({
className='z-10'
>
diff --git a/web/app/components/base/chat/chat/answer/index.tsx b/web/app/components/base/chat/chat/answer/index.tsx
index 84b397462c..581b031bab 100644
--- a/web/app/components/base/chat/chat/answer/index.tsx
+++ b/web/app/components/base/chat/chat/answer/index.tsx
@@ -2,7 +2,7 @@ import type {
FC,
ReactNode,
} from 'react'
-import { memo } from 'react'
+import { memo, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import type {
ChatConfig,
@@ -27,6 +27,7 @@ type AnswerProps = {
answerIcon?: ReactNode
responding?: boolean
allToolIcons?: Record
+ showPromptLog?: boolean
}
const Answer: FC = ({
item,
@@ -36,8 +37,10 @@ const Answer: FC = ({
answerIcon,
responding,
allToolIcons,
+ showPromptLog,
}) => {
const { t } = useTranslation()
+ const ref = useRef(null)
const {
content,
citation,
@@ -48,7 +51,7 @@ const Answer: FC = ({
const hasAgentThoughts = !!agent_thoughts?.length
return (
-
+
{
answerIcon || (
@@ -75,6 +78,8 @@ const Answer: FC
= ({
item={item}
question={question}
index={index}
+ showPromptLog={showPromptLog}
+ containerRef={ref}
/>
)
}
diff --git a/web/app/components/base/chat/chat/answer/operation.tsx b/web/app/components/base/chat/chat/answer/operation.tsx
index 8a791d82da..aeed0c9e4f 100644
--- a/web/app/components/base/chat/chat/answer/operation.tsx
+++ b/web/app/components/base/chat/chat/answer/operation.tsx
@@ -1,4 +1,4 @@
-import type { FC } from 'react'
+import type { FC, RefObject } from 'react'
import {
memo,
useMemo,
@@ -17,16 +17,21 @@ import {
ThumbsUp,
} from '@/app/components/base/icons/src/vender/line/alertsAndFeedback'
import TooltipPlus from '@/app/components/base/tooltip-plus'
+import Log from '@/app/components/app/chat/log'
type OperationProps = {
item: ChatItem
question: string
index: number
+ showPromptLog?: boolean
+ containerRef: RefObject
}
const Operation: FC = ({
item,
question,
index,
+ showPromptLog,
+ containerRef,
}) => {
const { t } = useTranslation()
const {
@@ -65,22 +70,29 @@ const Operation: FC = ({
return (
- {
- !isOpeningStatement && (
-
- )
- }
-
- {(!isOpeningStatement && config?.text_to_speech?.enabled) && (
-
)}
+
+
+ {showPromptLog && (
+
+ )}
+ {(!isOpeningStatement && config?.text_to_speech?.enabled) && (
+ <>
+
+
+ >
+ )}
+
+
{(!isOpeningStatement && config?.supportAnnotation && config.annotation_reply?.enabled) && (
file.belongs_to === 'assistant') || [],
+ },
+ ],
more: {
time: dayjs.unix(newResponseItem.created_at).format('hh:mm A'),
tokens: newResponseItem.answer_tokens + newResponseItem.message_tokens,
diff --git a/web/app/components/base/chat/chat/index.tsx b/web/app/components/base/chat/chat/index.tsx
index 2f3ae50131..8792eff759 100644
--- a/web/app/components/base/chat/chat/index.tsx
+++ b/web/app/components/base/chat/chat/index.tsx
@@ -160,6 +160,7 @@ const Chat: FC = ({
answerIcon={answerIcon}
responding={isLast && isResponding}
allToolIcons={allToolIcons}
+ showPromptLog={showPromptLog}
/>
)
}
@@ -167,9 +168,7 @@ const Chat: FC = ({
)
})
diff --git a/web/app/components/base/chat/chat/question.tsx b/web/app/components/base/chat/chat/question.tsx
index a123540a89..f8eaad1ce6 100644
--- a/web/app/components/base/chat/chat/question.tsx
+++ b/web/app/components/base/chat/chat/question.tsx
@@ -4,28 +4,21 @@ import type {
} from 'react'
import {
memo,
- useRef,
} from 'react'
import type { ChatItem } from '../types'
import { QuestionTriangle } from '@/app/components/base/icons/src/vender/solid/general'
import { User } from '@/app/components/base/icons/src/public/avatar'
-import Log from '@/app/components/app/chat/log'
import { Markdown } from '@/app/components/base/markdown'
import ImageGallery from '@/app/components/base/image-gallery'
type QuestionProps = {
item: ChatItem
- showPromptLog?: boolean
questionIcon?: ReactNode
- isResponding?: boolean
}
const Question: FC = ({
item,
- showPromptLog,
- isResponding,
questionIcon,
}) => {
- const ref = useRef(null)
const {
content,
message_files,
@@ -34,14 +27,9 @@ const Question: FC = ({
const imgSrcs = message_files?.length ? message_files.map(item => item.url) : []
return (
-
+
- {
- showPromptLog && !isResponding && (
-
- )
- }
{
!!imgSrcs.length && (
diff --git a/web/i18n/en-US/app-log.ts b/web/i18n/en-US/app-log.ts
index 59151b2c1f..5c86703db9 100644
--- a/web/i18n/en-US/app-log.ts
+++ b/web/i18n/en-US/app-log.ts
@@ -76,6 +76,8 @@ const translation = {
title: 'Conversation Log',
workflowTitle: 'Log Detail',
},
+ promptLog: 'Prompt Log',
+ viewLog: 'View Log',
}
export default translation
diff --git a/web/i18n/zh-Hans/app-log.ts b/web/i18n/zh-Hans/app-log.ts
index 7233be9ae3..111297fe6a 100644
--- a/web/i18n/zh-Hans/app-log.ts
+++ b/web/i18n/zh-Hans/app-log.ts
@@ -72,6 +72,8 @@ const translation = {
},
workflowTitle: '日志',
workflowSubtitle: '日志记录了应用的执行情况',
+ promptLog: 'Prompt 日志',
+ viewLog: '查看日志',
}
export default translation
diff --git a/web/models/log.ts b/web/models/log.ts
index e485a9d3b2..3b8509b1b7 100644
--- a/web/models/log.ts
+++ b/web/models/log.ts
@@ -77,8 +77,7 @@ export type MessageContent = {
conversation_id: string
query: string
inputs: Record
- // message: Record
- message: string
+ message: { role: string; text: string; files?: VisionFile[] }[]
message_tokens: number
answer_tokens: number
answer: string
@@ -101,6 +100,8 @@ export type MessageContent = {
from_end_user_id?: string
}>
message_files: VisionFile[]
+ agent_thoughts: any[] // TODO
+ workflow_run_id: string
}
export type CompletionConversationGeneralDetail = {