is_ai is set to true if sender is null

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-02-20 23:11:18 -03:00
commit 9adb4b97d4

View file

@ -41,9 +41,8 @@ export default function newChatView(): JSX.Element {
const outputTypes = outputs.map((obj) => obj.type); const outputTypes = outputs.map((obj) => obj.type);
useEffect(() => { useEffect(() => {
if(!outputTypes.includes("ChatOutput")) if (!outputTypes.includes("ChatOutput")) {
{ setNoticeData({ title: "There is no ChatOutput node in the flow." });
setNoticeData({title:"There is no ChatOutput node in the flow."})
} }
}, []); }, []);
@ -71,12 +70,16 @@ export default function newChatView(): JSX.Element {
try { try {
const { sender, message, sender_name } = output.data const { sender, message, sender_name } = output.data
.artifacts as ChatOutputType; .artifacts as ChatOutputType;
const is_ai = sender === "Machine";
const is_ai = sender === "Machine" || sender === null;
return { isSend: !is_ai, message: message, sender_name }; return { isSend: !is_ai, message: message, sender_name };
} } catch (e) {
catch(e){
console.error(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); setChatHistory(chatMessages);