Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
BillSchumacher committed Apr 19, 2023
1 parent 239d64a commit 6e94409
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions autogpt/json_utils/json_fix_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def fix_invalid_escape(json_to_load: str, error_message: str) -> str:
while error_message.startswith("Invalid \\escape"):
bad_escape_location = extract_char_position(error_message)
json_to_load = (
json_to_load[:bad_escape_location] + json_to_load[bad_escape_location + 1:]
json_to_load[:bad_escape_location] + json_to_load[bad_escape_location + 1 :]
)
try:
json.loads(json_to_load)
Expand Down Expand Up @@ -109,7 +109,7 @@ def correct_json(json_to_load: str) -> str:
if error_message.startswith("Invalid \\escape"):
json_to_load = fix_invalid_escape(json_to_load, error_message)
if error_message.startswith(
"Expecting property name enclosed in double quotes"
"Expecting property name enclosed in double quotes"
):
json_to_load = add_quotes_to_property_names(json_to_load)
try:
Expand Down
9 changes: 6 additions & 3 deletions autogpt/json_utils/json_fix_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

import contextlib
import json
from typing import Dict, Any
from typing import Any, Dict

from colorama import Fore
from regex import regex

from autogpt.config import Config
from autogpt.json_utils.json_fix_general import correct_json
from autogpt.llm_utils import call_ai_function
from autogpt.logs import logger
from autogpt.speech import say_text
from autogpt.config import Config

JSON_SCHEMA = """
{
Expand Down Expand Up @@ -102,7 +102,10 @@ def fix_json_using_multiple_techniques(assistant_reply: str) -> Dict[Any, Any]:
if assistant_reply_json != {}:
return assistant_reply_json

logger.error("Error: The following AI output couldn't be converted to a JSON:\n", assistant_reply)
logger.error(
"Error: The following AI output couldn't be converted to a JSON:\n",
assistant_reply,
)
if CFG.speak_mode:
say_text("I have received an invalid JSON response from the OpenAI API.")

Expand Down
2 changes: 1 addition & 1 deletion autogpt/json_utils/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from jsonschema import Draft7Validator

from autogpt.logs import logger
from autogpt.config import Config
from autogpt.logs import logger

CFG = Config()

Expand Down
5 changes: 4 additions & 1 deletion autogpt/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ def remove_color_codes(s: str) -> str:

def print_assistant_thoughts(ai_name, assistant_reply):
"""Prints the assistant's thoughts to the console"""
from autogpt.json_utils.json_fix_llm import fix_and_parse_json, attempt_to_fix_json_by_finding_outermost_brackets
from autogpt.json_utils.json_fix_llm import (
attempt_to_fix_json_by_finding_outermost_brackets,
fix_and_parse_json,
)

try:
try:
Expand Down

0 comments on commit 6e94409

Please sign in to comment.