|
13 | 13 | import pytest
|
14 | 14 |
|
15 | 15 | from autogen.agentchat.contrib.captainagent.agent_builder import AgentBuilder
|
| 16 | +from autogen.agentchat.contrib.text_analyzer_agent import TextAnalyzerAgent |
16 | 17 | from autogen.import_utils import optional_import_block, skip_on_missing_imports
|
17 | 18 |
|
18 | 19 | from ...conftest import KEY_LOC, OAI_CONFIG_LIST
|
@@ -122,6 +123,36 @@ def test_build_from_library(builder: AgentBuilder):
|
122 | 123 | assert len(agent_config["agent_configs"]) <= builder.max_agents
|
123 | 124 |
|
124 | 125 |
|
| 126 | +@pytest.mark.openai |
| 127 | +@skip_on_missing_imports(["openai"], "openai") |
| 128 | +def test_build_with_agent_configs(builder: AgentBuilder): |
| 129 | + conf = { |
| 130 | + "building_task": "Generate one TextAnalyzerAgent to analyze text", |
| 131 | + "agent_configs": [ |
| 132 | + { |
| 133 | + "name": "TextAnalyzerAgent", |
| 134 | + "model": ["gpt-4o"], |
| 135 | + "description": "A helpful assistant to analyze text. Ask them to analyze any text, and they will provide you with the analysis.", |
| 136 | + "system_message": "", |
| 137 | + "agent_path": "autogen/agentchat/contrib/text_analyzer_agent/TextAnalyzerAgent", |
| 138 | + } |
| 139 | + ], |
| 140 | + "coding": True, |
| 141 | + "default_llm_config": {"temperature": 0}, |
| 142 | + "code_execution_config": {"work_dir": ".", "use_docker": False, "timeout": 60, "last_n_messages": 2}, |
| 143 | + } |
| 144 | + |
| 145 | + agents, _ = builder.build(**conf) |
| 146 | + |
| 147 | + is_agent_found = False |
| 148 | + for agent in agents: |
| 149 | + if isinstance(agent, TextAnalyzerAgent): |
| 150 | + is_agent_found = True |
| 151 | + break |
| 152 | + |
| 153 | + assert is_agent_found, "TextAnalyzerAgent not found in agents" |
| 154 | + |
| 155 | + |
125 | 156 | @pytest.mark.openai
|
126 | 157 | @skip_on_missing_imports(["openai"], "openai")
|
127 | 158 | def test_save(builder: AgentBuilder):
|
|
0 commit comments