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.

Fix test_make_agent

Reinier van der Leer9943c58fbab0
diff --git a/autogpt/llm/api_manager.py b/autogpt/llm/api_manager.py
index 454b4f22b4..acc38c44cd 100644
--- a/autogpt/llm/api_manager.py
+++ b/autogpt/llm/api_manager.py
@@ -34,7 +34,7 @@ class ApiManager(metaclass=Singleton):
temperature: float = None,
max_tokens: int | None = None,
deployment_id=None,
- ) -> str:
+ ):
"""
Create a chat completion and update the cost.
Args:
diff --git a/autogpt/llm/utils/__init__.py b/autogpt/llm/utils/__init__.py
index fd7ba49f3f..736745cf89 100644
--- a/autogpt/llm/utils/__init__.py
+++ b/autogpt/llm/utils/__init__.py
@@ -242,7 +242,7 @@ def create_chat_completion(
max_tokens=max_tokens,
)
- resp = response.choices[0].message["content"]
+ resp = response.choices[0].message.content
for plugin in cfg.plugins:
if not plugin.can_handle_on_response():
continue
diff --git a/tests/unit/test_make_agent.py b/tests/unit/test_make_agent.py
index 23eea0278a..61a7a6f5d9 100644
--- a/tests/unit/test_make_agent.py
+++ b/tests/unit/test_make_agent.py
@@ -11,10 +11,11 @@ def test_make_agent(agent: Agent, mocker: MockerFixture) -> None:
mock = mocker.patch("openai.ChatCompletion.create")
response = MagicMock()
- # del response.error
- response.choices[0].messages[0].content = "Test message"
+ 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)