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.
Fixing circular imports
Luke2568164cb354
diff --git a/autogpt/llm/api_manager.py b/autogpt/llm/api_manager.pyindex 3a9d3eac41..afab6e4ae6 100644--- a/autogpt/llm/api_manager.py+++ b/autogpt/llm/api_manager.py@@ -5,7 +5,6 @@ from typing import List, Optionalimport openaifrom openai import Modelfrom autogpt.llm.base import CompletionModelInfo-from autogpt.llm.providers.openai import OPEN_AI_MODELSfrom autogpt.logs import loggerfrom autogpt.singleton import Singleton@@ -35,6 +34,7 @@ class ApiManager(metaclass=Singleton):model (str): The model used for the API call."""# the .model property in API responses can contain version suffixes like -v2+ from autogpt.llm.providers.openai import OPEN_AI_MODELSmodel = model[:-3] if model.endswith("-v2") else modelmodel_info = OPEN_AI_MODELS[model]diff --git a/autogpt/llm/providers/openai.py b/autogpt/llm/providers/openai.pyindex 08375aa8f8..707a7db8ac 100644--- a/autogpt/llm/providers/openai.py+++ b/autogpt/llm/providers/openai.py@@ -9,7 +9,6 @@ from colorama import Fore, Stylefrom openai.error import APIError, RateLimitError, Timeoutfrom openai.openai_object import OpenAIObject-from autogpt.llm.api_manager import ApiManagerfrom autogpt.llm.base import (ChatModelInfo,EmbeddingModelInfo,@@ -111,6 +110,7 @@ OPEN_AI_MODELS: dict[str, ChatModelInfo | EmbeddingModelInfo | TextModelInfo] =def meter_api(func):"""Adds ApiManager metering to functions which make OpenAI API calls"""+ from autogpt.llm.api_manager import ApiManagerapi_manager = ApiManager()openai_obj_processor = openai.util.convert_to_openai_objectdiff --git a/tests/integration/test_provider_openai.py b/tests/integration/test_provider_openai.pyindex f5ae65cf42..f51ad9ac4a 100644--- a/tests/integration/test_provider_openai.py+++ b/tests/integration/test_provider_openai.py@@ -2,7 +2,7 @@ from unittest.mock import MagicMock, patchimport pytest-from autogpt.llm.api_manager import COSTS, ApiManager+from autogpt.llm.api_manager import ApiManagerfrom autogpt.llm.providers import openaiapi_manager = ApiManager()@@ -14,19 +14,6 @@ def reset_api_manager():yield[email protected](autouse=True)-def mock_costs():- with patch.dict(- COSTS,- {- "gpt-3.5-turbo": {"prompt": 0.002, "completion": 0.002},- "text-embedding-ada-002": {"prompt": 0.0004, "completion": 0},- },- clear=True,- ):- yield--class TestProviderOpenAI:@staticmethoddef test_create_chat_completion_debug_mode(caplog):diff --git a/tests/unit/test_api_manager.py b/tests/unit/test_api_manager.pyindex e259f56adc..c29aadf5d6 100644--- a/tests/unit/test_api_manager.py+++ b/tests/unit/test_api_manager.py@@ -3,7 +3,8 @@ from unittest.mock import MagicMock, patchimport pytestfrom pytest_mock import MockerFixture-from autogpt.llm.api_manager import OPEN_AI_MODELS, ApiManager+from autogpt.llm.api_manager import ApiManager+from autogpt.llm.providers.openai import OPEN_AI_MODELSapi_manager = ApiManager()diff --git a/tests/unit/test_make_agent.py b/tests/unit/test_make_agent.pydeleted file mode 100644index 61a7a6f5d9..0000000000--- a/tests/unit/test_make_agent.py+++ /dev/null@@ -1,25 +0,0 @@-from unittest.mock import MagicMock--from pytest_mock import MockerFixture--from autogpt.agent.agent import Agent-from autogpt.app import list_agents, start_agent---def test_make_agent(agent: Agent, mocker: MockerFixture) -> None:- """Test that an agent can be created"""- mock = mocker.patch("openai.ChatCompletion.create")-- response = MagicMock()- response.choices[0].message.content = "Test message"- response.usage.prompt_tokens = 1- response.usage.completion_tokens = 1- del response.error-- mock.return_value = response- start_agent("Test Agent", "chat", "Hello, how are you?", agent, "gpt-3.5-turbo")- agents = list_agents(agent)- assert "List of agents:\n0: chat" == agents- start_agent("Test Agent 2", "write", "Hello, how are you?", agent, "gpt-3.5-turbo")- agents = list_agents(agent.config)- assert "List of agents:\n0: chat\n1: write" == agents