Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

refactor: Replace deprecated logger.warn calls with logger.warning

Reinier van der Leerffeb45eda34a
diff --git a/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py b/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py
index 8b8a697065..1bfe9f5bab 100644
--- a/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py
+++ b/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py
@@ -381,7 +381,7 @@ class OneShotAgentPromptStrategy(PromptStrategy):
try:
return format_numbered_list([cmd.fmt_line() for cmd in commands])
except AttributeError:
- self.logger.warn(f"Formatting commands failed. {commands}")
+ self.logger.warning(f"Formatting commands failed. {commands}")
raise
def parse_response_content(
diff --git a/autogpts/autogpt/autogpt/app/configurator.py b/autogpts/autogpt/autogpt/app/configurator.py
index e9f70ac3d2..fe4b88783f 100644
--- a/autogpts/autogpt/autogpt/app/configurator.py
+++ b/autogpts/autogpt/autogpt/app/configurator.py
@@ -178,13 +178,13 @@ def apply_overrides_to_config(
if allow_downloads:
print_attribute("Native Downloading", "ENABLED")
- logger.warn(
+ logger.warning(
msg=f"{Back.LIGHTYELLOW_EX}"
"AutoGPT will now be able to download and save files to your machine."
f"{Back.RESET}"
" It is recommended that you monitor any files it downloads carefully.",
)
- logger.warn(
+ logger.warning(
msg=f"{Back.RED + Style.BRIGHT}"
"NEVER OPEN FILES YOU AREN'T SURE OF!"
f"{Style.RESET_ALL}",
@@ -207,7 +207,7 @@ def check_model(
if any(model_name in m["id"] for m in models):
return model_name
- logger.warn(
+ logger.warning(
f"You don't have access to {model_name}. Setting {model_type} to gpt-3.5-turbo."
)
return "gpt-3.5-turbo"
diff --git a/autogpts/autogpt/autogpt/app/main.py b/autogpts/autogpt/autogpt/app/main.py
index 5f314f03b0..f50c22d3ab 100644
--- a/autogpts/autogpt/autogpt/app/main.py
+++ b/autogpts/autogpt/autogpt/app/main.py
@@ -112,7 +112,7 @@ async def run_auto_gpt(
if config.continuous_mode:
for line in get_legal_warning().split("\n"):
- logger.warn(
+ logger.warning(
extra={
"title": "LEGAL:",
"title_color": Fore.RED,
@@ -470,7 +470,7 @@ async def run_interaction_loop(
assistant_reply_dict,
) = await agent.propose_action()
except InvalidAgentResponseError as e:
- logger.warn(f"The agent's thoughts could not be parsed: {e}")
+ logger.warning(f"The agent's thoughts could not be parsed: {e}")
consecutive_failures += 1
if consecutive_failures >= 3:
logger.error(
@@ -532,7 +532,7 @@ async def run_interaction_loop(
extra={"color": Fore.MAGENTA},
)
elif user_feedback == UserFeedback.EXIT:
- logger.warn("Exiting...")
+ logger.warning("Exiting...")
exit()
else: # user_feedback == UserFeedback.TEXT
command_name = "human_feedback"
@@ -568,7 +568,7 @@ async def run_interaction_loop(
result, extra={"title": "SYSTEM:", "title_color": Fore.YELLOW}
)
elif result.status == "error":
- logger.warn(
+ logger.warning(
f"Command {command_name} returned an error: "
f"{result.error or result.reason}"
)
@@ -657,13 +657,13 @@ async def get_user_feedback(
if console_input.lower().strip() == config.authorise_key:
user_feedback = UserFeedback.AUTHORIZE
elif console_input.lower().strip() == "":
- logger.warn("Invalid input format.")
+ logger.warning("Invalid input format.")
elif console_input.lower().startswith(f"{config.authorise_key} -"):
try:
user_feedback = UserFeedback.AUTHORIZE
new_cycles_remaining = abs(int(console_input.split(" ")[1]))
except ValueError:
- logger.warn(
+ logger.warning(
f"Invalid input format. "
f"Please enter '{config.authorise_key} -N'"
" where N is the number of continuous tasks."
diff --git a/autogpts/autogpt/autogpt/app/utils.py b/autogpts/autogpt/autogpt/app/utils.py
index e7b337e9b9..6b21f180df 100644
--- a/autogpts/autogpt/autogpt/app/utils.py
+++ b/autogpts/autogpt/autogpt/app/utils.py
@@ -174,7 +174,7 @@ def print_motd(config: Config, logger: logging.Logger):
def print_git_branch_info(logger: logging.Logger):
git_branch = get_current_git_branch()
if git_branch and git_branch != "master":
- logger.warn(
+ logger.warning(
f"You are running on `{git_branch}` branch"
" - this is not a supported branch."
)
diff --git a/autogpts/autogpt/autogpt/commands/execute_code.py b/autogpts/autogpt/autogpt/commands/execute_code.py
index 8b376b3fd3..93bfd53d40 100644
--- a/autogpts/autogpt/autogpt/commands/execute_code.py
+++ b/autogpts/autogpt/autogpt/commands/execute_code.py
@@ -216,7 +216,7 @@ def execute_python_file(
return exec_result.output.decode("utf-8")
except DockerException as e:
- logger.warn(
+ logger.warning(
"Could not run the script in a container. "
"If you haven't already, please install Docker: "
"https://docs.docker.com/get-docker/"
diff --git a/autogpts/autogpt/autogpt/commands/file_operations.py b/autogpts/autogpt/autogpt/commands/file_operations.py
index ba2be0005e..ec61d5875f 100644
--- a/autogpts/autogpt/autogpt/commands/file_operations.py
+++ b/autogpts/autogpt/autogpt/commands/file_operations.py
@@ -190,7 +190,7 @@ def ingest_file(
logger.info(f"Ingested {len(file_memory.e_chunks)} chunks from {filename}")
except Exception as err:
- logger.warn(f"Error while ingesting file '{filename}': {err}")
+ logger.warning(f"Error while ingesting file '{filename}': {err}")
@command(
diff --git a/autogpts/autogpt/autogpt/core/resource/model_providers/openai.py b/autogpts/autogpt/autogpt/core/resource/model_providers/openai.py
index 70e4fd862f..81a5a01177 100644
--- a/autogpts/autogpt/autogpt/core/resource/model_providers/openai.py
+++ b/autogpts/autogpt/autogpt/core/resource/model_providers/openai.py
@@ -333,7 +333,7 @@ class OpenAIProvider(
try:
encoding = tiktoken.encoding_for_model(encoding_model)
except KeyError:
- cls._logger.warn(
+ cls._logger.warning(
f"Model {model_name} not found. Defaulting to cl100k_base encoding."
)
encoding = tiktoken.get_encoding("cl100k_base")
diff --git a/autogpts/autogpt/autogpt/memory/vector/__init__.py b/autogpts/autogpt/autogpt/memory/vector/__init__.py
index f7f38412d0..bcef31a415 100644
--- a/autogpts/autogpt/autogpt/memory/vector/__init__.py
+++ b/autogpts/autogpt/autogpt/memory/vector/__init__.py
@@ -69,7 +69,7 @@ def get_memory(config: Config) -> VectorMemory:
"https://github.com/Significant-Gravitas/AutoGPT/discussions/4280"
)
# if not PineconeMemory:
- # logger.warn(
+ # logger.warning(
# "Error: Pinecone is not installed. Please install pinecone"
# " to use Pinecone as a memory backend."
# )
@@ -84,7 +84,7 @@ def get_memory(config: Config) -> VectorMemory:
"the memory system, and has been removed temporarily."
)
# if not RedisMemory:
- # logger.warn(
+ # logger.warning(
# "Error: Redis is not installed. Please install redis-py to"
# " use Redis as a memory backend."
# )
@@ -99,7 +99,7 @@ def get_memory(config: Config) -> VectorMemory:
"https://github.com/Significant-Gravitas/AutoGPT/discussions/4280"
)
# if not WeaviateMemory:
- # logger.warn(
+ # logger.warning(
# "Error: Weaviate is not installed. Please install weaviate-client"
# " to use Weaviate as a memory backend."
# )
@@ -114,7 +114,7 @@ def get_memory(config: Config) -> VectorMemory:
"https://github.com/Significant-Gravitas/AutoGPT/discussions/4280"
)
# if not MilvusMemory:
- # logger.warn(
+ # logger.warning(
# "Error: pymilvus sdk is not installed, but required "
# "to use Milvus or Zilliz as memory backend. "
# "Please install pymilvus."
diff --git a/autogpts/autogpt/autogpt/memory/vector/providers/json_file.py b/autogpts/autogpt/autogpt/memory/vector/providers/json_file.py
index 8e9211c662..efab7e8f6e 100644
--- a/autogpts/autogpt/autogpt/memory/vector/providers/json_file.py
+++ b/autogpts/autogpt/autogpt/memory/vector/providers/json_file.py
@@ -42,7 +42,7 @@ class JSONFileMemory(VectorMemoryProvider):
self.load_index()
logger.debug(f"Loaded {len(self.memories)} MemoryItems from file")
except Exception as e:
- logger.warn(f"Could not load MemoryItems from file: {e}")
+ logger.warning(f"Could not load MemoryItems from file: {e}")
self.save_index()
def __iter__(self) -> Iterator[MemoryItem]:
diff --git a/autogpts/autogpt/autogpt/models/command_registry.py b/autogpts/autogpt/autogpt/models/command_registry.py
index bde1868b50..ec372c9f53 100644
--- a/autogpts/autogpt/autogpt/models/command_registry.py
+++ b/autogpts/autogpt/autogpt/models/command_registry.py
@@ -56,13 +56,13 @@ class CommandRegistry:
def register(self, cmd: Command) -> None:
if cmd.name in self.commands:
- logger.warn(
+ logger.warning(
f"Command '{cmd.name}' already registered and will be overwritten!"
)
self.commands[cmd.name] = cmd
if cmd.name in self.commands_aliases:
- logger.warn(
+ logger.warning(
f"Command '{cmd.name}' will overwrite alias with the same name of "
f"'{self.commands_aliases[cmd.name]}'!"
)
diff --git a/autogpts/autogpt/autogpt/plugins/__init__.py b/autogpts/autogpt/autogpt/plugins/__init__.py
index da4b089588..0b08a62e47 100644
--- a/autogpts/autogpt/autogpt/plugins/__init__.py
+++ b/autogpts/autogpt/autogpt/plugins/__init__.py
@@ -78,13 +78,13 @@ def fetch_openai_plugins_manifest_and_spec(config: Config) -> dict:
if response.status_code == 200:
manifest = response.json()
if manifest["schema_version"] != "v1":
- logger.warn(
+ logger.warning(
"Unsupported manifest version: "
f"{manifest['schem_version']} for {url}"
)
continue
if manifest["api"]["type"] != "openapi":
- logger.warn(
+ logger.warning(
f"Unsupported API type: {manifest['api']['type']} for {url}"
)
continue
@@ -92,11 +92,11 @@ def fetch_openai_plugins_manifest_and_spec(config: Config) -> dict:
manifest, f"{openai_plugin_client_dir}/ai-plugin.json"
)
else:
- logger.warn(
+ logger.warning(
f"Failed to fetch manifest for {url}: {response.status_code}"
)
except requests.exceptions.RequestException as e:
- logger.warn(f"Error while requesting manifest from {url}: {e}")
+ logger.warning(f"Error while requesting manifest from {url}: {e}")
else:
logger.info(f"Manifest for {url} already exists")
manifest = json.load(open(f"{openai_plugin_client_dir}/ai-plugin.json"))
@@ -128,7 +128,7 @@ def create_directory_if_not_exists(directory_path: str) -> bool:
logger.debug(f"Created directory: {directory_path}")
return True
except OSError as e:
- logger.warn(f"Error creating directory {directory_path}: {e}")
+ logger.warning(f"Error creating directory {directory_path}: {e}")
return False
else:
logger.info(f"Directory {directory_path} already exists")
@@ -167,7 +167,7 @@ def initialize_openai_plugins(manifests_specs: dict, config: Config) -> dict:
config=_config,
)
if client_results:
- logger.warn(
+ logger.warning(
f"Error creating OpenAPI client: {client_results[0].header} \n"
f" details: {client_results[0].detail}"
)
@@ -237,7 +237,7 @@ def scan_plugins(config: Config) -> List[AutoGPTPluginTemplate]:
plugin = sys.modules[qualified_module_name]
if not plugins_config.is_enabled(plugin_module_name):
- logger.warn(
+ logger.warning(
f"Plugin folder {plugin_module_name} found but not configured. "
"If this is a legitimate plugin, please add it to plugins_config.yaml "
f"(key: {plugin_module_name})."
@@ -293,7 +293,7 @@ def scan_plugins(config: Config) -> List[AutoGPTPluginTemplate]:
"Disabled in plugins_config.yaml."
)
elif not plugin_configured:
- logger.warn(
+ logger.warning(
f"Not loading plugin {plugin_name}. "
f"No entry for '{plugin_name}' in plugins_config.yaml. "
"Note: Zipped plugins should use the class name "
@@ -316,7 +316,9 @@ def scan_plugins(config: Config) -> List[AutoGPTPluginTemplate]:
for url, openai_plugin_meta in manifests_specs_clients.items():
if not plugins_config.is_enabled(url):
plugin_name = openai_plugin_meta["manifest"]["name_for_model"]
- logger.warn(f"OpenAI Plugin {plugin_name} found but not configured")
+ logger.warning(
+ f"OpenAI Plugin {plugin_name} found but not configured"
+ )
continue
plugin = BaseOpenAIPlugin(openai_plugin_meta)
diff --git a/autogpts/autogpt/autogpt/plugins/plugins_config.py b/autogpts/autogpt/autogpt/plugins/plugins_config.py
index a58118172d..0494b6e383 100644
--- a/autogpts/autogpt/autogpt/plugins/plugins_config.py
+++ b/autogpts/autogpt/autogpt/plugins/plugins_config.py
@@ -64,7 +64,7 @@ class PluginsConfig(BaseModel):
plugins_allowlist: list[str],
) -> dict[str, PluginConfig]:
if not plugins_config_file.is_file():
- logger.warn("plugins_config.yaml does not exist, creating base config.")
+ logger.warning("plugins_config.yaml does not exist, creating base config.")
cls.create_empty_plugins_config(
plugins_config_file,
plugins_denylist,
diff --git a/autogpts/autogpt/autogpt/speech/eleven_labs.py b/autogpts/autogpt/autogpt/speech/eleven_labs.py
index 06fee58e71..897f0fd7d2 100644
--- a/autogpts/autogpt/autogpt/speech/eleven_labs.py
+++ b/autogpts/autogpt/autogpt/speech/eleven_labs.py
@@ -88,6 +88,6 @@ class ElevenLabsSpeech(VoiceBase):
os.remove("speech.mpeg")
return True
else:
- logger.warn("Request failed with status code:", response.status_code)
+ logger.warning("Request failed with status code:", response.status_code)
logger.info("Response content:", response.content)
return False