+ {message.usedTools.map((tool, index) => {
+ return (
+ onSourceDialogClick(tool, 'Used Tools')}
+ />
+ )
+ })}
+
+ )}
+ {message.artifacts && (
+
+ {message.artifacts.map((item, index) => {
+ return item !== null ? (
+ <>{renderArtifacts(item, index)}>
+ ) : null
+ })}
+
+ )}
{/* Messages are being rendered in Markdown format */}
{
+ artifacts.forEach((artifact) => {
+ if (artifact.type === 'png' || artifact.type === 'jpeg') {
+ artifact.data = `${baseURL}/api/v1/get-upload-file?chatflowId=${chatflowid}&chatId=${chatId}&fileName=${artifact.data.replace(
+ 'FILE-STORAGE::',
+ ''
+ )}`
+ }
+ })
+ setMessages((prevMessages) => {
+ let allMessages = [...cloneDeep(prevMessages)]
+ if (allMessages[allMessages.length - 1].type === 'userMessage') return allMessages
+ allMessages[allMessages.length - 1].artifacts = artifacts
+ return allMessages
+ })
+ }
+
const updateLastMessageNextAgent = (nextAgent) => {
setMessages((prevMessages) => {
let allMessages = [...cloneDeep(prevMessages)]
@@ -730,6 +747,7 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
fileAnnotations: data?.fileAnnotations,
agentReasoning: data?.agentReasoning,
action: data?.action,
+ artifacts: data?.artifacts,
type: 'apiMessage',
feedback: null
}
@@ -792,6 +810,9 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
case 'agentReasoning':
updateLastMessageAgentReasoning(payload.data)
break
+ case 'artifacts':
+ updateLastMessageArtifacts(payload.data)
+ break
case 'action':
updateLastMessageAction(payload.data)
break
@@ -913,6 +934,17 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
if (message.fileAnnotations) obj.fileAnnotations = message.fileAnnotations
if (message.agentReasoning) obj.agentReasoning = message.agentReasoning
if (message.action) obj.action = message.action
+ if (message.artifacts) {
+ obj.artifacts = message.artifacts
+ obj.artifacts.forEach((artifact) => {
+ if (artifact.type === 'png' || artifact.type === 'jpeg') {
+ artifact.data = `${baseURL}/api/v1/get-upload-file?chatflowId=${chatflowid}&chatId=${chatId}&fileName=${artifact.data.replace(
+ 'FILE-STORAGE::',
+ ''
+ )}`
+ }
+ })
+ }
if (message.fileUploads) {
obj.fileUploads = message.fileUploads
obj.fileUploads.forEach((file) => {
@@ -1260,6 +1292,84 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
}
}
+ const agentReasoningArtifacts = (artifacts) => {
+ const newArtifacts = cloneDeep(artifacts)
+ for (let i = 0; i < newArtifacts.length; i++) {
+ const artifact = newArtifacts[i]
+ if (artifact && (artifact.type === 'png' || artifact.type === 'jpeg')) {
+ const data = artifact.data
+ newArtifacts[i].data = `${baseURL}/api/v1/get-upload-file?chatflowId=${chatflowid}&chatId=${chatId}&fileName=${data.replace(
+ 'FILE-STORAGE::',
+ ''
+ )}`
+ }
+ }
+ return newArtifacts
+ }
+
+ const renderArtifacts = (item, index, isAgentReasoning) => {
+ if (item.type === 'png' || item.type === 'jpeg') {
+ return (
+
+
+
+ )
+ } else if (item.type === 'html') {
+ return (
+
+ )
+ } else {
+ return (
+
+ ) : (
+
+ {children}
+
+ )
+ }
+ }}
+ >
+ {item.data}
+
+ )
+ }
+ }
+
return (
{isDragActive && (
@@ -1459,6 +1569,23 @@ export const ChatMessage = ({ open, chatflowid, isAgentCanvas, isDialog, preview
/>
)}
+ {agent.artifacts && (
+
+ {agentReasoningArtifacts(agent.artifacts).map((item, index) => {
+ return item !== null ? (
+ <>{renderArtifacts(item, index, true)}>
+ ) : null
+ })}
+
+ )}
{agent.messages.length > 0 && (
)}
+ {message.artifacts && (
+
+ {message.artifacts.map((item, index) => {
+ return item !== null ? <>{renderArtifacts(item, index)}> : null
+ })}
+
+ )}
{message.type === 'leadCaptureMessage' &&
!getLocalStorageChatflow(chatflowid)?.lead &&