From d12da33e55ec026be8cc5efdcaab4172e8d5631e Mon Sep 17 00:00:00 2001 From: Andy Melnikov Date: Mon, 10 Apr 2023 18:46:40 +0200 Subject: [PATCH] Fix flake8 W293 and W391 --- scripts/ai_config.py | 1 - scripts/browse.py | 2 +- scripts/chat.py | 4 ++-- scripts/json_parser.py | 6 +++--- scripts/main.py | 1 - 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/ai_config.py b/scripts/ai_config.py index 1d5832c18..2a4854cb9 100644 --- a/scripts/ai_config.py +++ b/scripts/ai_config.py @@ -92,4 +92,3 @@ class AIConfig: full_prompt += f"\n\n{data.load_prompt()}" return full_prompt - diff --git a/scripts/browse.py b/scripts/browse.py index 09f376a70..b0c745ef4 100644 --- a/scripts/browse.py +++ b/scripts/browse.py @@ -15,7 +15,7 @@ def scrape_text(url): # Most basic check if the URL is valid: if not url.startswith('http'): return "Error: Invalid URL" - + # Restrict access to local files if check_local_file_access(url): return "Error: Access to local files is restricted" diff --git a/scripts/chat.py b/scripts/chat.py index c00e4d4a6..23e5b5014 100644 --- a/scripts/chat.py +++ b/scripts/chat.py @@ -63,10 +63,10 @@ def chat_with_ai( """ model = cfg.fast_llm_model # TODO: Change model from hardcode to argument # Reserve 1000 tokens for the response - + if cfg.debug: print(f"Token limit: {token_limit}") - + send_token_limit = token_limit - 1000 relevant_memory = permanent_memory.get_relevant(str(full_message_history[-5:]), 10) diff --git a/scripts/json_parser.py b/scripts/json_parser.py index 1fd682440..8c17dfa25 100644 --- a/scripts/json_parser.py +++ b/scripts/json_parser.py @@ -71,11 +71,11 @@ def fix_and_parse_json( return json_str else: raise e - - + + def fix_json(json_str: str, schema: str) -> str: """Fix the given JSON string to make it parseable and fully complient with the provided schema.""" - + # Try to fix the JSON using gpt: function_string = "def fix_json(json_str: str, schema:str=None) -> str:" args = [f"'''{json_str}'''", f"'''{schema}'''"] diff --git a/scripts/main.py b/scripts/main.py index 8661bfad1..217461188 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -415,4 +415,3 @@ while True: chat.create_chat_message( "system", "Unable to execute command")) print_to_console("SYSTEM: ", Fore.YELLOW, "Unable to execute command") -