Merge branch 'master' into dev

This commit is contained in:
Andres Caicedo
2023-04-03 16:37:11 +02:00
4 changed files with 9 additions and 9 deletions

1
.gitignore vendored
View File

@@ -8,3 +8,4 @@ scripts/auto_gpt_workspace/*
*.mpeg
.env
last_run_ai_settings.yaml
outputs/*

View File

@@ -1,6 +1,7 @@
# Auto-GPT: An Autonomous GPT-4 Experiment
![GitHub Repo stars](https://img.shields.io/github/stars/Torantulino/auto-gpt?style=social)
![Twitter Follow](https://img.shields.io/twitter/follow/siggravitas?style=social)
[![](https://dcbadge.vercel.app/api/server/PQ7VX6TY4t?style=flat)](https://discord.gg/PQ7VX6TY4t)
Auto-GPT is an experimental open-source application showcasing the capabilities of the GPT-4 language model. This program, driven by GPT-4, autonomously develops and manages businesses to increase net worth. As one of the first examples of GPT-4 running fully autonomously, Auto-GPT pushes the boundaries of what is possible with AI.

View File

@@ -1,6 +1,5 @@
beautifulsoup4
colorama==0.4.6
dirtyjson==1.0.
openai==0.27.2
playsound==1.3.0
python-dotenv==1.0.0
@@ -9,5 +8,5 @@ readability-lxml==0.8.1
requests
tiktoken==0.3.3
docker
# googlesearch-python
googlesearch-python
# Googlesearch python seems to be a bit cursed, anyone good at fixing thigns like this?

View File

@@ -1,4 +1,4 @@
import dirtyjson
import json
from call_ai_function import call_ai_function
from config import Config
cfg = Config()
@@ -25,7 +25,7 @@ def fix_and_parse_json(json_str: str, try_to_fix_with_gpt: bool = True):
"""
try:
return dirtyjson.loads(json_str)
return json.loads(json_str)
except Exception as e:
# Let's do something manually - sometimes GPT responds with something BEFORE the braces:
# "I'm sorry, I don't understand. Please try again."{"text": "I'm sorry, I don't understand. Please try again.", "confidence": 0.0}
@@ -35,21 +35,20 @@ def fix_and_parse_json(json_str: str, try_to_fix_with_gpt: bool = True):
json_str = json_str[brace_index:]
last_brace_index = json_str.rindex("}")
json_str = json_str[:last_brace_index+1]
return dirtyjson.loads(json_str)
return json.loads(json_str)
except Exception as e:
if try_to_fix_with_gpt:
print(f"Warning: Failed to parse AI output, attempting to fix.\n If you see this warning frequently, it's likely that your prompt is confusing the AI. Try changing it up slightly.")
# Now try to fix this up using the ai_functions
ai_fixed_json = fix_json(json_str, json_schema, False)
if ai_fixed_json != "failed":
return dirtyjson.loads(ai_fixed_json)
return json.loads(ai_fixed_json)
else:
print(f"Failed to fix ai output, telling the AI.") # This allows the AI to react to the error message, which usually results in it correcting its ways.
return json_str
else:
raise e
# TODO: Make debug a global config var
def fix_json(json_str: str, schema: str, debug=False) -> str:
"""Fix the given JSON string to make it parseable and fully complient with the provided schema."""
# Try to fix the JSON using gpt:
@@ -70,10 +69,10 @@ def fix_json(json_str: str, schema: str, debug=False) -> str:
print(f"Fixed JSON: {result_string}")
print("----------- END OF FIX ATTEMPT ----------------")
try:
return dirtyjson.loads(result_string)
return json.loads(result_string)
except:
# Get the call stack:
# import traceback
# call_stack = traceback.format_exc()
# print(f"Failed to fix JSON: '{json_str}' "+call_stack)
return "failed"
return "failed"