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

Syntax Error in AI-Generated Code Snippet with TypeScript (TSX) in Code Sandbox #1

Open
Yash-Patidar opened this issue Aug 2, 2024 · 7 comments

Comments

@Yash-Patidar
Copy link

When generating a code snippet using the AI model, the code is rendered with an incorrect syntax that causes a syntax error in a TypeScript (TSX) file. The generated code snippet includes "```tsx" at the beginning, which is not a valid TypeScript syntax and results in an error when executed.

prompt : build the chat APP
AI model : Gemma 2 27B
Screenshot from 2024-08-03 02-22-49

@syeddhasnainn
Copy link

did you try again? working fine for me on all of the models

@Nutlope
Copy link
Owner

Nutlope commented Aug 3, 2024

I tried to optimize the prompt so this shouldn't happen! Lemme know if it's still happening

@Yash-Patidar
Copy link
Author

Screenshot from 2024-08-03 12-20-58
Yes, I am still facing the same issue. However, sometimes it works well when we try again.

@kamaravichow
Copy link

Try removing such tags with regex

          text = text.replace(/```(tsx|typescript|javascript)?/g, "");

@yavin5
Copy link

yavin5 commented Aug 3, 2024

Yes, it's still happening. Maybe infrequently, but it is. The TS code can filter those out, as @kamaravichow said above.

@Nutlope
Copy link
Owner

Nutlope commented Aug 3, 2024

Sounds good, thanks for letting me know! I reviewed @kamaravichow's PR and requested some changes, so we'll try to get this fixed :)

@jachenms
Copy link

jachenms commented Aug 4, 2024

image
how to solve the issue when run my prompt

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

No branches or pull requests

6 participants