mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-02-10 16:54:20 +01:00
refactor: Replace deprecated logger.warn calls with logger.warning
- Replaced all instances of logger.warn with logger.warning to get rid of deprecation warnings.
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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."
|
||||
)
|
||||
|
||||
@@ -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/"
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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]:
|
||||
|
||||
@@ -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]}'!"
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user