meirk
meirk5mo ago

streaming assitant template is returning this error:

Could not send message: Unexpected token 'ש', "שלום! איך "... is not valid JSON in the widget testing mode
Solution:
Hey @meirk, could you please check the "Advanced Options" section, and see if "Response is a stream" is enabled?
No description
Jump to solution
7 Replies
Solution
nithinrdy
nithinrdy5mo ago
Hey @meirk, could you please check the "Advanced Options" section, and see if "Response is a stream" is enabled?
No description
nithinrdy
nithinrdy5mo ago
We're working on making this feature a bit more streamlined, so that this toggle option won't be necessary. In the mean time, please ensure the toggle is correctly enabled/disabled as needed. Let me know if this helps.
meirk
meirk5mo ago
Yes, this solved the problem!
What is the purpose of the header key x-thread-id?
nithinrdy
nithinrdy5mo ago
It returns the thread Id to the chat widget. This allows the widget to track the conversation you have with the Assistant (so if it weren't for this header, the assistant will react to every message as if it's the first message in the thread -- i.e. it will have no memory of the previous messages in the conversation).
meirk
meirk5mo ago
And why the no streaming template doesnt use it?
nithinrdy
nithinrdy5mo ago
Because the standard assistant template returns a JSON, so one of the properties returns the message, while the other returns the thread ID, like so:
{
"message": "...",
"threadId": "..."
}
{
"message": "...",
"threadId": "..."
}
But in case of a stream response it's not possible to return a JSON like that, because the response is a stream of text. So there needs to be a different way to return the thread ID in case of a stream. Returning it through the response header is one such way.
meirk
meirk5mo ago
I see.. thanks a lot