Chat Component Double Replies

I am starting a new thread, since this one was closed, as I am having the same issue.

It is easily re-producible too. All I did was drop the default chat component and let it create the default query and wiring. Type hi and get two replies

i have the same issue

I don't think this is something we can fix, it seems it's more like a backend problem, but to make a bandaid you can add a transformer to the query w return ([ - 1].sender ===[ - 2].sender ?, -1) : data). the ternary check is incase this gets fixed without you knowing, so you don't have to remember to remove the transformer later on in the future.

Won't the message history start to inflate with double replies? I get that would fix the display of the chat, but like you said, still a band-aid on the backend.

ya, unfortunately that's not as easy of a fix. The AI Chat component gives you access to the message history, but in workflows it has to be supplied. It is still possible, here's how I solved it:

couple notes:

  • you do need to add user_id to the worflow input
  • this uses the sample_user table in the Retool Database (PostgreSQL) so if you use a different resource altogether to store users you can change line 3 in the first block to user_id int UNIQUE {{ }}

or if you're using that component from the pic in your original post you set Message History to {{ chat1.messageHistory.length % 2 ? chat1.messageHistory.slice(0, -1) : chat1.messageHistory }} it's not as versatile as the transformer suggestion I made, but it will remove the last message from the history if there are ever an odd number of messages in the message list. i can't remember if the newest message sent by the user is added to the .data before or after sending the message but you might need to change it chat1.messageHistory.length % 2 === 0

I think I am going to hold off for now on "chatting" and stick to just text generation, as I want to summarize something. Interactive would be better, but for now, a single shot summary will work for me.

1 Like

Hi @khill-fbmc Thanks for resurfacing this! I still haven't been able to reproduce this issue, but we'll flag it to the team internally for a fix.

Curious to hear more about your summary project if you're able to participate in the AI Challenge :tada: