From 749469e10062e2468e9d943cd054e35f58aaca55 Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Fri, 7 Jun 2024 15:28:12 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(chatView/index.tsx):=20fix=20ch?= =?UTF-8?q?at=20message=20filtering=20to=20handle=20nested=20messages=20ar?= =?UTF-8?q?ray=20=E2=99=BB=EF=B8=8F=20(api/index.ts):=20rename=20'message'?= =?UTF-8?q?=20to=20'messages'=20in=20VertexDataTypeAPI=20for=20clarity=20a?= =?UTF-8?q?nd=20consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modals/IOModal/components/chatView/index.tsx | 11 +++++++---- src/frontend/src/types/api/index.ts | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/modals/IOModal/components/chatView/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/index.tsx index f228a63de..8e7fb2cda 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/index.tsx @@ -62,11 +62,14 @@ export default function ChatView({ const chatMessages: ChatMessageType[] = chatOutputResponses .sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp)) // - .filter((output) => output.data.message) + .filter( + (output) => + output?.data?.messages && output?.data?.messages?.length > 0, + ) .map((output, index) => { try { const { sender, message, sender_name, stream_url, files } = output - .data.message as ChatOutputType; + ?.data?.messages[0] as ChatOutputType; const is_ai = sender === "Machine" || sender === null; return { @@ -131,7 +134,7 @@ export default function ChatView({ function updateChat( chat: ChatMessageType, message: string, - stream_url?: string + stream_url?: string, ) { // if (message === "") return; chat.message = message; @@ -160,7 +163,7 @@ export default function ChatView({ const { dragOver, dragEnter, dragLeave, onDrop } = useDragAndDrop( setIsDragging, setFiles, - currentFlowId + currentFlowId, ); return ( diff --git a/src/frontend/src/types/api/index.ts b/src/frontend/src/types/api/index.ts index 0ba428a98..ca704a137 100644 --- a/src/frontend/src/types/api/index.ts +++ b/src/frontend/src/types/api/index.ts @@ -162,7 +162,7 @@ export type VertexBuildTypeAPI = { export type VertexDataTypeAPI = { results: { [key: string]: string }; logs: { message: any; type: string }[]; - message: ChatOutputType | ChatInputType; + messages: ChatOutputType[] | ChatInputType[]; inactive?: boolean; timedelta?: number; duration?: string;