Skip to content

Conversation

@Parthavi19
Copy link

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.

Copy link
Member

@PrakharDoneria PrakharDoneria left a 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'

Copy link
Member

@PrakharDoneria PrakharDoneria left a 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

@Parthavi19
Copy link
Author

sure will do that

@Parthavi19
Copy link
Author

Removed dependency on fuzzy_json as it's not available on PyPI and causes a ModuleNotFoundError and also updated the requirements.txt file

This improves portability and simplifies the dependency tree.

@PrakharDoneria
Copy link
Member

image

I still fell some issues out there after your latest Pull Request. Can you please fix the ai_engine.py logics and make it work then just ping me here.

@PrakharDoneria PrakharDoneria added the gssoc This issue was assigned as a part of GSSoC 2025 contribution. label Aug 3, 2025
@PrakharDoneria PrakharDoneria linked an issue Aug 3, 2025 that may be closed by this pull request
@Parthavi19
Copy link
Author

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 I hope its fine now. Please let me know if any changes need to be made

@PrakharDoneria
Copy link
Member

Can you please make a video or share screenshot showing the process in which AI is making website, in my device AI is showing error

image

@Parthavi19
Copy link
Author

@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

@PrakharDoneria
Copy link
Member

@Parthavi19 the process to check working of ai_engine.py is to run the ui.py file then pass some prompt to it and check if AI is working correctly or not.

@PrakharDoneria PrakharDoneria added the invalid This doesn't seem right label Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc This issue was assigned as a part of GSSoC 2025 contribution. invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] AI service returns JSON parsing error on prompt

2 participants