yoheinakajima / instagraph

Converts text input or URL into knowledge graph and displays
MIT License
3.28k stars 282 forks source link

Json correction #26

Closed velocitatem closed 1 year ago

velocitatem commented 1 year ago

Hi! Love the project! I observed that when dealing with larger inputs, the integration often struggles to properly parse the JSON data, usually due to trailing commas. To address this, I've implemented a function that automatically corrects the JSON formatting for those cases :)

Summary by CodeRabbit

Release Notes

yoheinakajima commented 1 year ago

Hey I love this! I'm reviewing from mobile which makes why merge conflicts hard to manage, but if you're able to fix happy to pull this in!

coderabbitai[bot] commented 1 year ago

Walkthrough

The changes primarily focus on enhancing the handling of OpenAI's JSON response. A new function correct_json() is introduced to ensure the validity of the JSON data. The get_response_data() function now utilizes this correction mechanism and returns a tuple for better error handling.

Changes

File Summary
main.py Introduced correct_json() to validate and correct JSON responses from OpenAI. Updated get_response_data() to use this function and return a tuple (response_data, 200). Minor formatting updates and comments added for clarity.

🐇💻

In the land of code, where the brackets lie,

A rabbit hopped in, with an eagle's eye.

Fixed some JSON, made it shine,

Now the data flows, oh so fine!

With tuples returned, and errors caught,

A better script, the rabbit has wrought! 🎉

Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - Mention `@coderabbitai` in any *review comment* for bot assistance. - Note: Review comments are made on code diffs or files, not on the PR overview. ### Pause Incremental Reviews - Insert `@coderabbitai: ignore` in the PR description to halt the bot's ongoing reviews. Remove the line to resume.