From 9adb4b97d46b2f3b03ad6674d9a3dba3a2e60a4b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 20 Feb 2024 23:11:18 -0300 Subject: [PATCH] is_ai is set to true if sender is null --- .../src/components/newChatView/index.tsx | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/frontend/src/components/newChatView/index.tsx b/src/frontend/src/components/newChatView/index.tsx index 8c4a769fb..65220ae7e 100644 --- a/src/frontend/src/components/newChatView/index.tsx +++ b/src/frontend/src/components/newChatView/index.tsx @@ -30,7 +30,7 @@ export default function newChatView(): JSX.Element { getFlow, CleanFlowPool, } = useFlowStore(); - const { setErrorData,setNoticeData } = useAlertStore(); + const { setErrorData, setNoticeData } = useAlertStore(); const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId); const [lockChat, setLockChat] = useState(false); const messagesRef = useRef(null); @@ -41,11 +41,10 @@ export default function newChatView(): JSX.Element { const outputTypes = outputs.map((obj) => obj.type); useEffect(() => { - if(!outputTypes.includes("ChatOutput")) - { - setNoticeData({title:"There is no ChatOutput node in the flow."}) + if (!outputTypes.includes("ChatOutput")) { + setNoticeData({ title: "There is no ChatOutput node in the flow." }); } - },[]); + }, []); //build chat history useEffect(() => { @@ -68,15 +67,19 @@ export default function newChatView(): JSX.Element { .sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp)) .filter((output) => !!output.data.artifacts?.message) .map((output) => { - try{ + try { const { sender, message, sender_name } = output.data - .artifacts as ChatOutputType; - const is_ai = sender === "Machine"; - return { isSend: !is_ai, message: message, sender_name }; - } - catch(e){ + .artifacts as ChatOutputType; + + const is_ai = sender === "Machine" || sender === null; + return { isSend: !is_ai, message: message, sender_name }; + } catch (e) { console.error(e); - return { isSend: false, message: "Error parsing message", sender_name: "Error" }; + return { + isSend: false, + message: "Error parsing message", + sender_name: "Error", + }; } }); setChatHistory(chatMessages);