Make the json_parser more robust

For some reason the bot keeps prefacing its JSON. This fixes it for now.
This commit is contained in:
Taylor Brown
2023-04-02 18:50:51 -05:00
parent a47da497b5
commit 3e587bc7fb
5 changed files with 160 additions and 58 deletions

View File

@@ -8,12 +8,13 @@ from config import Config
import ai_functions as ai
from file_operations import read_file, write_to_file, append_to_file, delete_file
from execute_code import execute_python_file
from json_parser import fix_and_parse_json
cfg = Config()
def get_command(response):
try:
response_json = json.loads(response)
response_json = fix_and_parse_json(response)
command = response_json["command"]
command_name = command["name"]
arguments = command["args"]