-
Notifications
You must be signed in to change notification settings - Fork 58
JSON parsing in ai_engine.py #82
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
base: main
Are you sure you want to change the base?
Conversation
PrakharDoneria
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ModuleNotFoundError: No module named 'fuzzy_json'
PrakharDoneria
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add all required modules in requirements.txt
|
sure will do that |
|
Removed dependency on This improves portability and simplifies the dependency tree. |
|
Made a few changes in the ai_engine.py file and i implemented robust JSON extraction strategies with fallback handling for malformed AI responses and enhanced input validation. |
|
@PrakharDoneria Basically the ai_engine.py code is running successfully in my system but its not opening the web UI builder properly. Like its just showing a blank page in my Mac but i shared the changes i have made so far in case it worked for you. I am trying to rectify it and i'll send the updated code in few days because its still showing a blank page |
|
@Parthavi19 the process to check working of |


Root Cause:
The extract_json() function attempted to parse the entire response string as JSON, even when the AI returned:
Explanations before/after the JSON block
Extra characters after the valid JSON
Solution:
Updated extract_json() to safely extract the first complete JSON block using a bracket-counting method.
Stripped any markdown/code fences using regular expressions.
Retained fuzzy_json as a fallback for resilience.
Added better logging and error handling for transparency.
Changes Made:
Enhanced extract_json() logic to prevent partial/extra-data parsing.
Improved log outputs for cleaned and parsed responses.
Strengthened prompt instructions in generate_code_from_prompt() to avoid malformed responses.