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.
Prevent docker compose to break config by creating folders (#4125)
k-boikov360d5cd577b9
diff --git a/autogpt/config/ai_config.py b/autogpt/config/ai_config.pyindex 88acbfe6fb..0599f10480 100644--- a/autogpt/config/ai_config.py+++ b/autogpt/config/ai_config.py@@ -73,7 +73,7 @@ class AIConfig:try:with open(config_file, encoding="utf-8") as file:- config_params = yaml.load(file, Loader=yaml.FullLoader)+ config_params = yaml.load(file, Loader=yaml.FullLoader) or {}except FileNotFoundError:config_params = {}diff --git a/autogpt/config/config.py b/autogpt/config/config.pyindex c5ffc60c2c..7e8c0c37a6 100644--- a/autogpt/config/config.py+++ b/autogpt/config/config.py@@ -210,7 +210,7 @@ class Config(metaclass=Singleton):None"""with open(config_file) as file:- config_params = yaml.load(file, Loader=yaml.FullLoader)+ config_params = yaml.load(file, Loader=yaml.FullLoader) or {}self.openai_api_type = config_params.get("azure_api_type") or "azure"self.openai_api_base = config_params.get("azure_api_base") or ""self.openai_api_version = (diff --git a/docs/setup.md b/docs/setup.mdindex 70b3ac3959..14244b8b34 100644--- a/docs/setup.md+++ b/docs/setup.md@@ -60,9 +60,14 @@ Get your OpenAI API key from: [https://platform.openai.com/account/api-keys](htt- ./data:/app/data## allow auto-gpt to write logs to disk- ./logs:/app/logs- ## uncomment following lines if you have / want to make use of these files- #- ./azure.yaml:/app/azure.yaml- #- ./ai_settings.yaml:/app/ai_settings.yaml+ ## uncomment following lines if you want to make use of these files+ ## you must have them existing in the same folder as this docker-compose.yml+ #- type: bind+ # source: ./azure.yaml+ # target: /app/azure.yaml+ #- type: bind+ # source: ./ai_settings.yaml+ # target: /app/ai_settings.yamlredis:image: "redis/redis-stack-server:latest"diff --git a/tests/test_ai_config.py b/tests/test_ai_config.pyindex a9fcdad68e..a684373b89 100644--- a/tests/test_ai_config.py+++ b/tests/test_ai_config.py@@ -43,3 +43,32 @@ ai_role: A hungry AIapi_budget: 0.0"""assert config_file.read_text() == yaml_content2+++def test_ai_config_file_not_exists(workspace):+ """Test if file does not exist."""++ config_file = workspace.get_path("ai_settings.yaml")++ ai_config = AIConfig.load(str(config_file))+ assert ai_config.ai_name == ""+ assert ai_config.ai_role == ""+ assert ai_config.ai_goals == []+ assert ai_config.api_budget == 0.0+ assert ai_config.prompt_generator is None+ assert ai_config.command_registry is None+++def test_ai_config_file_is_empty(workspace):+ """Test if file does not exist."""++ config_file = workspace.get_path("ai_settings.yaml")+ config_file.write_text("")++ ai_config = AIConfig.load(str(config_file))+ assert ai_config.ai_name == ""+ assert ai_config.ai_role == ""+ assert ai_config.ai_goals == []+ assert ai_config.api_budget == 0.0+ assert ai_config.prompt_generator is None+ assert ai_config.command_registry is Nonediff --git a/tests/test_config.py b/tests/test_config.pyindex 0f38b28cd9..98134dc851 100644--- a/tests/test_config.py+++ b/tests/test_config.py@@ -4,6 +4,7 @@ for the AI and ensures it behaves as a singleton."""from unittest.mock import patch+import pytestfrom openai import InvalidRequestErrorfrom autogpt.configurator import create_config@@ -155,3 +156,17 @@ def test_smart_and_fast_llm_models_set_to_gpt4(mock_list_models, config):# Reset configconfig.set_fast_llm_model(fast_llm_model)config.set_smart_llm_model(smart_llm_model)+++def test_missing_azure_config(config, workspace):+ config_file = workspace.get_path("azure_config.yaml")+ with pytest.raises(FileNotFoundError):+ config.load_azure_config(str(config_file))++ config_file.write_text("")+ config.load_azure_config(str(config_file))++ assert config.openai_api_type == "azure"+ assert config.openai_api_base == ""+ assert config.openai_api_version == "2023-03-15-preview"+ assert config.azure_model_to_deployment_id_map == {}