You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
node chat_with_streaming.js
Chat Stream:
It's subjective to determine theundefined:1{"id": "cmpl-794d708af6ed43aeab6a2a81390c5d90", "object": "chat.completion.chunk", "created": 1702672109, "model": "mistral-tiny", "choices": [{"index": 0, "delta": {"role": null, "content": " \"best\" French cheese as people have different preferences basedSyntaxError: Unterminated string in JSON at position 258 at JSON.parse (<anonymous>) at MistralClient.chatStream (file:///Users/bracesproul/code/mistral-client-js/src/client.js:184:24) at chatStream.next (<anonymous>) at file:///Users/bracesproul/code/mistral-client-js/examples/chat_with_streaming.js:13:18 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)Node.js v20.10.0
Streaming works because continue allows for the error to not be thrown.
And Error parsing chunk data. is logged anywhere between 5-8 times (ran the example ~5 times)
The text was updated successfully, but these errors were encountered:
bracesproul
changed the title
Streaming example throws SyntaxError: Unterminated string in JSON at position ... error.
Streaming example throws JSON SyntaxErrorDec 15, 2023
Yeah, I'm getting this issue too. The issue is the the SSE data comes in chunks that don't always form complete JSON objects. The library will need to buffer the incomplete chunks until it get's a complete line/json object. #12 is the same problem, with a suggested reference solution.
If I modify the client streaming code to this:
Streaming works because
continue
allows for the error to not be thrown.And
Error parsing chunk data.
is logged anywhere between 5-8 times (ran the example ~5 times)The text was updated successfully, but these errors were encountered: