fixie-ai / ai-jsx

The AI Application Framework for Javascript
https://docs.ai-jsx.com
MIT License
1.03k stars 76 forks source link

Bugfix: removing partial unicode when streaming #512

Closed farzadab closed 7 months ago

farzadab commented 7 months ago

Bugfix for issue reported on Discord: Partially streaming Chinese (and other unicode) characters could cause an error when calling JSON.parse. This PR fixes improves the untruncateJson to also truncate such cases. As an extra measure (possibly unneeded), I added a try/catch around JSON.parse while streaming so that it doesn't throw an error. This will simply lead to the frame being skipped and no information should be lost.

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai-jsx-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2023 6:06pm
ai-jsx-nextjs-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2023 6:06pm
ai-jsx-tutorial-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2023 6:06pm
ai-jsx-voice ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2023 6:06pm