Files
Auto-GPT/tests/test_agent_manager.py
Media 5de1025520 Agent and agent manager tests (#3116)
* Update Python version and benchmark file in benchmark.yml

* Refactor main function and imports in cli.py

* Update import statement in ai_config.py

* Add set_temperature and set_memory_backend methods in config.py

* Remove unused import in prompt.py

* Add goal oriented tasks workflow

* Added agent_utils to create agent

* added pytest and vcrpy

* added write file cassette

* created goal oriented task write file with cassettes to not pay openai tokens

* solve conflicts

* add ability set azure because github workflow needs it off

* solve conflicts in cli.py

* black because linter fails

* solve conflict

* setup github action to v3

Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>

* fix conflicts

Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>

* Plugins: debug line always printed in plugin load

* add decorator to tests

Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>

* move decorator higher up

Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>

* init

* more tests

* passing tests

* skip gitbranch decorator on ci

* decorator skiponci

* black

* Update tests/utils.py decorator of skipping ci

Co-authored-by: Nicholas Tindle <nicktindle@outlook.com>

* black

* I oopsed the name

* black

* finally

* simple tests for agent and manager

* ísort

---------

Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>
Co-authored-by: Merwane Hamadi <merwanehamadi@gmail.com>
Co-authored-by: Merwane Hamadi <merwane.hamadi@redica.com>
Co-authored-by: Richard Beales <rich@richbeales.net>
Co-authored-by: Nicholas Tindle <nick@ntindle.com>
Co-authored-by: BillSchumacher <34168009+BillSchumacher@users.noreply.github.com>
Co-authored-by: Nicholas Tindle <nicktindle@outlook.com>
2023-04-24 14:19:42 -05:00

59 lines
1.6 KiB
Python

from typing import List
import pytest
from autogpt.agent.agent_manager import AgentManager
from tests.utils import requires_api_key
@pytest.fixture
def agent_manager():
return AgentManager()
@pytest.fixture
def task():
return "translate English to French"
@pytest.fixture
def prompt():
return "Translate the following English text to French: 'Hello, how are you?'"
@pytest.fixture
def model():
return "gpt-4"
@requires_api_key("OPENAI_API_KEY")
def test_create_agent(agent_manager, task, prompt, model):
key, agent_reply = agent_manager.create_agent(task, prompt, model)
assert isinstance(key, int)
assert isinstance(agent_reply, str)
assert key in agent_manager.agents
@requires_api_key("OPENAI_API_KEY")
def test_message_agent(agent_manager, task, prompt, model):
key, _ = agent_manager.create_agent(task, prompt, model)
user_message = "Please translate 'Good morning' to French."
agent_reply = agent_manager.message_agent(key, user_message)
assert isinstance(agent_reply, str)
@requires_api_key("OPENAI_API_KEY")
def test_list_agents(agent_manager, task, prompt, model):
key, _ = agent_manager.create_agent(task, prompt, model)
agents_list = agent_manager.list_agents()
assert isinstance(agents_list, list)
assert (key, task) in agents_list
@requires_api_key("OPENAI_API_KEY")
def test_delete_agent(agent_manager, task, prompt, model):
key, _ = agent_manager.create_agent(task, prompt, model)
success = agent_manager.delete_agent(key)
assert success
assert key not in agent_manager.agents