Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

Add roleplaying test (#259)

Tianqi Xu03e3c3f53806
diff --git a/test/agents/test_role_playing.py b/test/agents/test_role_playing.py
index dca115dc5..390a74f8f 100644
--- a/test/agents/test_role_playing.py
+++ b/test/agents/test_role_playing.py
@@ -14,6 +14,8 @@
import pytest
from camel.agents import ChatAgent, CriticAgent
+from camel.configs import FunctionCallingConfig
+from camel.functions import MATH_FUNCS
from camel.human import Human
from camel.messages import BaseMessage
from camel.societies import RolePlaying
@@ -115,3 +117,32 @@ def test_role_playing_step(task_type, extend_sys_msg_meta_dicts,
assert isinstance(response.terminated, bool)
assert response.terminated is False
assert isinstance(response.info, dict)
+
+
+def test_role_playing_with_function():
+ function_list = [*MATH_FUNCS]
+ assistant_model_config = FunctionCallingConfig.from_openai_function_list(
+ function_list=function_list)
+
+ role_playing = RolePlaying(
+ assistant_role_name="AI Assistant",
+ assistant_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO,
+ model_config=assistant_model_config,
+ function_list=function_list),
+ user_role_name="AI User",
+ user_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO),
+ task_prompt="Perform the task",
+ task_specify_agent_kwargs=dict(model=ModelType.GPT_3_5_TURBO),
+ task_type=TaskType.AI_SOCIETY,
+ )
+
+ init_assistant_msg, _ = role_playing.init_chat()
+ assistant_response, user_response = role_playing.step(init_assistant_msg)
+ for response in (assistant_response, user_response):
+ assert isinstance(response.msgs, list)
+ assert len(response.msgs) == 1
+ assert isinstance(response.msgs[0], BaseMessage)
+ assert isinstance(response.terminated, bool)
+ assert response.terminated is False
+ assert isinstance(response.info, dict)
diff --git a/test/functions/test_search_functions.py b/test/functions/test_search_functions.py
index 07f3fd75d..6ddec61f2 100644
--- a/test/functions/test_search_functions.py
+++ b/test/functions/test_search_functions.py
@@ -63,7 +63,7 @@ def test_search_wiki_not_found():
def tests_earch_wiki_by_api():
expected_output = (
"New York, often called New York State, is a state in the "
- "Northeastern United States. A Mid-Atlantic state, New York "
+ "Northeastern United States. A Mid-Atlantic state, New York "
"borders New England, and has an international border with "
"Canada. With almost 19.7 million residents, it is the fourth-most"
" populous state in the United States and seventh-most densely "