Add missing json_parser.py and add alternative requirements

This adds fix_and_parse_json
Also, add requirements-alternative.txt to help install reqs in a different environment
This commit is contained in:
Taylor Brown
2023-04-02 17:34:11 -05:00
parent 2b5a7cc485
commit dca5b78bfe
3 changed files with 30 additions and 1 deletions

12
scripts/json_parser.py Normal file
View File

@@ -0,0 +1,12 @@
import dirtyjson
from ai_functions import fix_json
def fix_and_parse_json(json_str: str, try_to_fix_with_gpt: bool = True):
try:
return dirtyjson.loads(json_str)
except Exception as e:
if try_to_fix_with_gpt:
# Now try to fix this up using the ai_functions
return fix_json(json_str, None, True)
else:
raise e

View File

@@ -0,0 +1,16 @@
# I wasn't having any luck installing the requirements.txt file in Mac or Linux,
# so I unpinned and installed, and got these versions:
beautifulsoup4==4.9.3
colorama==0.4.6
dirtyjson==1.0.8
# The biggest difference is docker 5 instead of 6, because of this silliness:
# The conflict is caused by:
# The user requested requests>=2.26.0
# docker 6.0.1 depends on requests>=2.26.0
# googlesearch-python 1.1.0 depends on requests==2.25.1
docker==5.0.3
googlesearch-python==1.1.0
openai==0.27.2
playsound==1.3.0
readability-lxml==0.8.1
requests==2.25.1

View File

@@ -1,8 +1,9 @@
beautifulsoup4==4.9.3 beautifulsoup4==4.9.3
colorama==0.4.6 colorama==0.4.6
dirtyjson==1.0.8
docker==6.0.1
googlesearch_python==1.1.0 googlesearch_python==1.1.0
openai==0.27.0 openai==0.27.0
playsound==1.2.2 playsound==1.2.2
readability_lxml==0.8.1 readability_lxml==0.8.1
requests==2.25.1 requests==2.25.1
docker==6.0.1