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.
Merge remote-tracking branch 'origin/master' into fix_agents
Gershon Bialer6a3fcda7516c
diff --cc autogpt/app.pyindex 122b453e0e,8d9cc9eeab..96bedd9217--- a/autogpt/app.py+++ b/autogpt/app.py@@@ -264,11 -257,22 +257,22 @@@ def message_agent(key: str, message: stdef list_agents():- """List all agents"""- return "List of agents:\n" + "\n".join([str(x[0]) + ": " + x[1] for x in agents.list_agents()])+ """List all agents++ Returns:- list: A list of all agents++ str: A list of all agents+ """- return AGENT_MANAGER.list_agents()++ return "List of agents:\n" + "\n".join([str(x[0]) + ": " + x[1] for x in AGENT_MANAGER.list_agents()])+++ def delete_agent(key: str) -> str:+ """Delete an agent with a given key+ Args:+ key (str): The key of the agent to delete- def delete_agent(key):- """Delete an agent with a given key"""- result = agents.delete_agent(key)+ Returns:+ str: A message indicating whether the agent was deleted or not+ """+ result = AGENT_MANAGER.delete_agent(key)return f"Agent {key} deleted." if result else f"Agent {key} does not exist."diff --cc tests/unit/test_commands.pyindex 9bb4c9c42b,0000000000..21982f7e63mode 100644,000000..100644--- a/tests/unit/test_commands.py+++ b/tests/unit/test_commands.py@@@ -1,17 -1,0 +1,18 @@@- from autogpt import commands++import autogpt.agent.agent_manager as agent_manager++from autogpt.app import start_agent, list_agents+import unittest+from unittest.mock import patch, MagicMock+++class TestCommands(unittest.TestCase):+ def test_make_agent(self):+ with patch("openai.ChatCompletion.create") as mock:+ obj = MagicMock()+ obj.response.choices[0].messages[0].content = "Test message"+ mock.return_value = obj- commands.start_agent("Test Agent", "chat", "Hello, how are you?", "gpt2")- agents = commands.list_agents()++ start_agent("Test Agent", "chat", "Hello, how are you?", "gpt2")++ agents = list_agents()+ self.assertEqual("List of agents:\n0: chat", agents)- commands.start_agent("Test Agent 2", "write", "Hello, how are you?", "gpt2")- agents = commands.list_agents()++ start_agent("Test Agent 2", "write", "Hello, how are you?", "gpt2")++ agents = list_agents()+ self.assertEqual("List of agents:\n0: chat\n1: write", agents)