deep-chat
deep-chat copied to clipboard
Handling multiple message responses?
Hey there, thanks so much for releasing this -- much appreciated!
I'm having a bit of trouble rendering multiple message responses I'm receiving from my backend.
Here's my Vue template code:
<deep-chat
:demo="true"
:initialMessages="thread.messages"
:request="{
handler: sendMessage
}"
/>
And here's my sendMessage helper function, which attempts to fire off multiple signals:
const sendMessage = async (body, signals) => {
try {
const response = await useRequest(`/threads/${thread.value.id}/message/`, {
method: 'POST',
body: {
message: body.messages[0].text,
}
})
response.forEach((message) => {
signals.onResponse(message)
})
} catch (e) {
useErrorHandler(e)
}
}
This only ever prints the first message, I assume signals.onResponse is only ever meant to be called once? It's not apparent to me how to make this call multiple times.. probably missing something very simple, appreciate any help, thanks!