Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: removing partial unicode when streaming #512

Merged
merged 6 commits into from
Nov 27, 2023

Conversation

farzadab
Copy link
Contributor

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.

Copy link

vercel bot commented Nov 24, 2023

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

packages/ai-jsx/src/lib/openai.tsx Outdated Show resolved Hide resolved
packages/ai-jsx/src/lib/util.ts Outdated Show resolved Hide resolved
@farzadab farzadab merged commit 524cf2d into main Nov 27, 2023
7 checks passed
@farzadab farzadab deleted the farzad/fix-partial-unicode branch November 27, 2023 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants