1- # This file has been modified by the Nextpy Team in 2023 using AI tools and automation scripts.
1+ # This file has been modified by the Nextpy Team in 2023 using AI tools and automation scripts.
22# We have rigorously tested these modifications to ensure reliability and performance. Based on successful test results, we are confident in the quality and stability of these changes.
33
44from unittest .mock import MagicMock
77
88from nextpy .ai .agent .base_agent import AgentState , BaseAgent
99from nextpy .ai .memory .base import BaseMemory
10- from nextpy .ai .tools . basetool import BaseTool
10+ from nextpy .ai .skills . base import BaseSkill
1111
1212
13- class MockBaseTool ( BaseTool ):
14- # Assuming BaseTool does not have any mandatory methods
13+ class MockBaseSkill ( BaseSkill ):
14+ # Assuming BaseSkill does not have any mandatory methods
1515 pass
1616
1717
@@ -64,15 +64,17 @@ def clear(self) -> None:
6464
6565@pytest .fixture
6666def base_agent_obj ():
67- """Return a BaseAgent object with mock base tools and memory. This is a context manager to allow unit tests to run."""
68- tools = [
69- MockBaseTool (name = "MockTool1" , description = "Mock description for tool 1" ),
70- MockBaseTool (name = "MockTool2" , description = "Mock description for tool 2" ),
67+ """Return a BaseAgent object with mock base skills and memory. This is a context manager to allow unit tests to run."""
68+ skills = [
69+ MockBaseSkill (name = "Mockskill1" ,
70+ description = "Mock description for skill 1" ),
71+ MockBaseSkill (name = "Mockskill2" ,
72+ description = "Mock description for skill 2" ),
7173 ]
7274 memory = MockMemory ()
7375 agent = BaseAgent (
7476 rag = MagicMock (),
75- tools = tools ,
77+ skills = skills ,
7678 llm = MagicMock (),
7779 prompt_template = "Test Prompt" ,
7880 input_variables = {"knowledge_variable" : "knowledge_variable" },
@@ -85,42 +87,43 @@ def base_agent_obj():
8587 yield agent # use yield to ensure cleanup after tests have run
8688
8789
88- def test_init_with_tools (base_agent_obj ):
89- """Tests init with tools . This is a test to make sure we don't accidentally get the tools from the Agent object after it has been initialized.
90+ def test_init_with_skills (base_agent_obj ):
91+ """Tests init with skills . This is a test to make sure we don't accidentally get the skills from the Agent object after it has been initialized.
9092
9193
9294 Args:
9395 base_agent_obj: An instance of the
9496 """
95- assert len (base_agent_obj .tools ) == 2
97+ assert len (base_agent_obj .skills ) == 2
9698 assert base_agent_obj .state == AgentState .IDLE
9799 # assert base_agent_obj.get_knowledge_variable == "Test"
98100
99101
100- def test_add_tool (base_agent_obj ):
101- """Tests adding a tool to the base agent. This is a convenience method to make sure we don't accidentally add tools that are already in the list.
102+ def test_add_skill (base_agent_obj ):
103+ """Tests adding a skill to the base agent. This is a convenience method to make sure we don't accidentally add skills that are already in the list.
102104
103105
104106 Args:
105107 base_agent_obj: An instance of BaseAgent
106108 """
107- new_tool = MockBaseTool (name = "MockTool3" , description = "Mock description for tool 3" )
108- base_agent_obj .add_tool (new_tool )
109- assert len (base_agent_obj .tools ) == 3
110- assert new_tool in base_agent_obj .tools
109+ new_skill = MockBaseSkill (
110+ name = "Mockskill3" , description = "Mock description for skill 3" )
111+ base_agent_obj .add_skill (new_skill )
112+ assert len (base_agent_obj .skills ) == 3
113+ assert new_skill in base_agent_obj .skills
111114
112115
113- def test_remove_tool (base_agent_obj ):
114- """Remove a tool from the base agent. Checks that it is removed and no more tools are added.
116+ def test_remove_skill (base_agent_obj ):
117+ """Remove a skill from the base agent. Checks that it is removed and no more skills are added.
115118
116119
117120 Args:
118121 base_agent_obj: An instance of : class : ` yum. manufacturers. base_agent. YumAgent
119122 """
120- tool = base_agent_obj .tools [0 ]
121- base_agent_obj .remove_tool ( tool )
122- assert len (base_agent_obj .tools ) == 1
123- assert tool not in base_agent_obj .tools
123+ skill = base_agent_obj .skills [0 ]
124+ base_agent_obj .remove_skill ( skill )
125+ assert len (base_agent_obj .skills ) == 1
126+ assert skill not in base_agent_obj .skills
124127
125128
126129# @patch('llms.agent.base_agent.engine')
0 commit comments