Merge pull request #1471 from gersh/fix_agents
Fix list_agents to return string instead of JSON objectpull/1656/head
commit
e0590e08d7
|
@ -276,9 +276,9 @@ def 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:
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
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
|
||||
start_agent("Test Agent", "chat", "Hello, how are you?", "gpt2")
|
||||
agents = list_agents()
|
||||
self.assertEqual("List of agents:\n0: chat", 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)
|
Loading…
Reference in New Issue