Skip to content

Commit 6e94409

Browse files
linting
1 parent 239d64a commit 6e94409

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

autogpt/json_utils/json_fix_general.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def fix_invalid_escape(json_to_load: str, error_message: str) -> str:
2727
while error_message.startswith("Invalid \\escape"):
2828
bad_escape_location = extract_char_position(error_message)
2929
json_to_load = (
30-
json_to_load[:bad_escape_location] + json_to_load[bad_escape_location + 1:]
30+
json_to_load[:bad_escape_location] + json_to_load[bad_escape_location + 1 :]
3131
)
3232
try:
3333
json.loads(json_to_load)
@@ -109,7 +109,7 @@ def correct_json(json_to_load: str) -> str:
109109
if error_message.startswith("Invalid \\escape"):
110110
json_to_load = fix_invalid_escape(json_to_load, error_message)
111111
if error_message.startswith(
112-
"Expecting property name enclosed in double quotes"
112+
"Expecting property name enclosed in double quotes"
113113
):
114114
json_to_load = add_quotes_to_property_names(json_to_load)
115115
try:

autogpt/json_utils/json_fix_llm.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
import contextlib
66
import json
7-
from typing import Dict, Any
7+
from typing import Any, Dict
88

99
from colorama import Fore
1010
from regex import regex
1111

12+
from autogpt.config import Config
1213
from autogpt.json_utils.json_fix_general import correct_json
1314
from autogpt.llm_utils import call_ai_function
1415
from autogpt.logs import logger
1516
from autogpt.speech import say_text
16-
from autogpt.config import Config
1717

1818
JSON_SCHEMA = """
1919
{
@@ -102,7 +102,10 @@ def fix_json_using_multiple_techniques(assistant_reply: str) -> Dict[Any, Any]:
102102
if assistant_reply_json != {}:
103103
return assistant_reply_json
104104

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

autogpt/json_utils/utilities.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from jsonschema import Draft7Validator
66

7-
from autogpt.logs import logger
87
from autogpt.config import Config
8+
from autogpt.logs import logger
99

1010
CFG = Config()
1111

autogpt/logs.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ def remove_color_codes(s: str) -> str:
204204

205205
def print_assistant_thoughts(ai_name, assistant_reply):
206206
"""Prints the assistant's thoughts to the console"""
207-
from autogpt.json_utils.json_fix_llm import fix_and_parse_json, attempt_to_fix_json_by_finding_outermost_brackets
207+
from autogpt.json_utils.json_fix_llm import (
208+
attempt_to_fix_json_by_finding_outermost_brackets,
209+
fix_and_parse_json,
210+
)
208211

209212
try:
210213
try:

0 commit comments

Comments
 (0)