From 42a0dfcec9330a5a1b949f5bcb542e32fe4f1042 Mon Sep 17 00:00:00 2001 From: Zaina Date: Fri, 18 Jul 2025 16:55:56 +0300 Subject: [PATCH] changed all role to instructions --- aixplain/factories/agent_factory/__init__.py | 4 +-- aixplain/factories/agent_factory/utils.py | 2 +- .../factories/team_agent_factory/__init__.py | 2 +- .../factories/team_agent_factory/utils.py | 2 +- aixplain/modules/agent/__init__.py | 2 +- aixplain/modules/team_agent/__init__.py | 2 +- tests/unit/agent/agent_factory_utils_test.py | 2 +- tests/unit/agent/agent_test.py | 26 +++++++++---------- tests/unit/team_agent/team_agent_test.py | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/aixplain/factories/agent_factory/__init__.py b/aixplain/factories/agent_factory/__init__.py index a00fe3bc..576a6e4a 100644 --- a/aixplain/factories/agent_factory/__init__.py +++ b/aixplain/factories/agent_factory/__init__.py @@ -72,7 +72,7 @@ def create( Args: name (Text): name of the agent description (Text): description of the agent role. - instructions (Text): role of the agent. + instructions (Text): instructions of the agent. llm (Optional[Union[LLM, Text]], optional): LLM instance to use as an object or as an ID. llm_id (Optional[Text], optional): ID of LLM to use if no LLM instance provided. Defaults to None. tools (List[Union[Tool, Model]], optional): list of tool for the agent. Defaults to []. @@ -113,7 +113,7 @@ def create( "name": name, "assets": [build_tool_payload(tool) for tool in tools], "description": description, - "role": instructions or description, + "instructions": instructions or description, "supplier": supplier, "version": version, "llmId": llm_id, diff --git a/aixplain/factories/agent_factory/utils.py b/aixplain/factories/agent_factory/utils.py index 450da273..658e9efd 100644 --- a/aixplain/factories/agent_factory/utils.py +++ b/aixplain/factories/agent_factory/utils.py @@ -177,7 +177,7 @@ def build_agent(payload: Dict, tools: List[Tool] = None, api_key: Text = config. name=payload.get("name", ""), tools=payload_tools, description=payload.get("description", ""), - instructions=payload.get("role"), + instructions=payload.get("instructions"), supplier=payload.get("teamId", None), version=payload.get("version", None), cost=payload.get("cost", None), diff --git a/aixplain/factories/team_agent_factory/__init__.py b/aixplain/factories/team_agent_factory/__init__.py index 77f9fad4..39c5ef79 100644 --- a/aixplain/factories/team_agent_factory/__init__.py +++ b/aixplain/factories/team_agent_factory/__init__.py @@ -160,7 +160,7 @@ def create( "version": version, "status": "draft", "tools": [], - "role": instructions, + "instructions": instructions, } # Add LLM tools to the payload diff --git a/aixplain/factories/team_agent_factory/utils.py b/aixplain/factories/team_agent_factory/utils.py index 16b65641..7a8fa886 100644 --- a/aixplain/factories/team_agent_factory/utils.py +++ b/aixplain/factories/team_agent_factory/utils.py @@ -82,7 +82,7 @@ def build_team_agent(payload: Dict, agents: List[Agent] = None, api_key: Text = name=payload.get("name", ""), agents=payload_agents, description=payload.get("description", ""), - instructions=payload.get("role", None), + instructions=payload.get("instructions", None), supplier=payload.get("teamId", None), version=payload.get("version", None), cost=payload.get("cost", None), diff --git a/aixplain/modules/agent/__init__.py b/aixplain/modules/agent/__init__.py index e3ca6f89..1d99dcdc 100644 --- a/aixplain/modules/agent/__init__.py +++ b/aixplain/modules/agent/__init__.py @@ -370,7 +370,7 @@ def to_dict(self) -> Dict: "name": self.name, "assets": [build_tool_payload(tool) for tool in self.tools], "description": self.description, - "role": self.instructions or self.description, + "instructions": self.instructions or self.description, "supplier": (self.supplier.value["code"] if isinstance(self.supplier, Supplier) else self.supplier), "version": self.version, "llmId": self.llm_id if self.llm is None else self.llm.id, diff --git a/aixplain/modules/team_agent/__init__.py b/aixplain/modules/team_agent/__init__.py index fa1aca9e..0fa6e2fe 100644 --- a/aixplain/modules/team_agent/__init__.py +++ b/aixplain/modules/team_agent/__init__.py @@ -356,7 +356,7 @@ def to_dict(self) -> Dict: "supplier": self.supplier.value["code"] if isinstance(self.supplier, Supplier) else self.supplier, "version": self.version, "status": self.status.value, - "role": self.instructions, + "instructions": self.instructions, } def _validate(self) -> None: diff --git a/tests/unit/agent/agent_factory_utils_test.py b/tests/unit/agent/agent_factory_utils_test.py index 59486242..5c7fbb77 100644 --- a/tests/unit/agent/agent_factory_utils_test.py +++ b/tests/unit/agent/agent_factory_utils_test.py @@ -224,7 +224,7 @@ def test_build_tool_success_cases(tool_dict, expected_type, expected_attrs, mock "id": "test_agent", "name": "Test Agent", "description": "Test Description", - "role": "Test Instructions", + "instructions": "Test Instructions", "teamId": "test_team", "version": "1.0", "cost": 10.0, diff --git a/tests/unit/agent/agent_test.py b/tests/unit/agent/agent_test.py index a93c35a8..28f706fb 100644 --- a/tests/unit/agent/agent_test.py +++ b/tests/unit/agent/agent_test.py @@ -139,7 +139,7 @@ def test_create_agent(mock_model_factory_get): "id": "123", "name": "Test Agent(-)", "description": "Test Agent Description", - "role": "Test Agent Role", + "instructions": "Test Agent Instruction", "teamId": "123", "version": "1.0", "status": "draft", @@ -203,7 +203,7 @@ def test_create_agent(mock_model_factory_get): assert agent.name == ref_response["name"] assert agent.description == ref_response["description"] - assert agent.instructions == ref_response["role"] + assert agent.instructions == ref_response["instructions"] assert agent.llm_id == ref_response["llmId"] assert agent.tools[0].function.value == ref_response["assets"][0]["function"] assert agent.tools[0].description == ref_response["assets"][0]["description"] @@ -231,7 +231,7 @@ def test_to_dict(): assert agent_json["id"] == "" assert agent_json["name"] == "Test Agent(-)" assert agent_json["description"] == "Test Agent Description" - assert agent_json["role"] == "Test Agent Role" + assert agent_json["instructions"] == "Test Agent Instructions" assert agent_json["llmId"] == "6646261c6eb563165658bbb1" assert agent_json["assets"][0]["function"] == "text-generation" assert agent_json["assets"][0]["type"] == "model" @@ -264,7 +264,7 @@ def test_update_success(mock_model_factory_get): "id": "123", "name": "Test Agent(-)", "description": "Test Agent Description", - "role": "Test Agent Role", + "instructions": "Test Agent Instructions", "teamId": "123", "version": "1.0", "status": "onboarded", @@ -305,7 +305,7 @@ def test_update_success(mock_model_factory_get): assert agent.id == ref_response["id"] assert agent.name == ref_response["name"] assert agent.description == ref_response["description"] - assert agent.instructions == ref_response["role"] + assert agent.instructions == ref_response["instructions"] assert agent.llm_id == ref_response["llmId"] assert agent.tools[0].function.value == ref_response["assets"][0]["function"] @@ -336,7 +336,7 @@ def test_save_success(mock_model_factory_get): "id": "123", "name": "Test Agent(-)", "description": "Test Agent Description", - "role": "Test Agent Role", + "instructions": "Test Agent Instructions", "teamId": "123", "version": "1.0", "status": "onboarded", @@ -382,7 +382,7 @@ def test_save_success(mock_model_factory_get): assert agent.id == ref_response["id"] assert agent.name == ref_response["name"] assert agent.description == ref_response["description"] - assert agent.instructions == ref_response["role"] + assert agent.instructions == ref_response["instructions"] assert agent.llm_id == ref_response["llmId"] assert agent.tools[0].function.value == ref_response["assets"][0]["function"] @@ -503,7 +503,7 @@ def test_agent_factory_create_without_instructions(): "id": "123", "name": "Test Agent", "description": "Test Agent Description", - "role": "Test Agent Description", # Should fallback to description + "instructions": "Test Agent Description", # Should fallback to description "teamId": "123", "version": "1.0", "status": "draft", @@ -544,7 +544,7 @@ def test_agent_factory_create_without_instructions(): sent_payload = sent_request.json() # The role should be set to description when instructions is None - assert sent_payload["role"] == "Test Agent Description" + assert sent_payload["instructions"] == "Test Agent Description" assert sent_payload["description"] == "Test Agent Description" @@ -557,7 +557,7 @@ def test_agent_to_dict_payload_without_instructions(): payload = agent.to_dict() # Check that role falls back to description when instructions is None - assert payload["role"] == "Test Description" # Should fallback to description + assert payload["instructions"] == "Test Description" # Should fallback to description assert payload["description"] == "Test Description" assert agent.instructions is None @@ -571,7 +571,7 @@ def test_agent_to_dict_payload_with_instructions(): payload = agent.to_dict() # Check that role uses instructions when provided - assert payload["role"] == "Custom Instructions" + assert payload["instructions"] == "Custom Instructions" assert payload["description"] == "Test Description" assert agent.instructions == "Custom Instructions" @@ -606,7 +606,7 @@ def test_agent_factory_create_with_explicit_none_instructions(): "id": "123", "name": "Test Agent", "description": "Test Agent Description", - "role": "Test Agent Description", # Should fallback to description + "instructions": "Test Agent Description", # Should fallback to description "teamId": "123", "version": "1.0", "status": "draft", @@ -645,7 +645,7 @@ def test_agent_factory_create_with_explicit_none_instructions(): sent_payload = sent_request.json() # The role should be set to description when instructions is None - assert sent_payload["role"] == "Test Agent Description" + assert sent_payload["instructions"] == "Test Agent Description" assert sent_payload["description"] == "Test Agent Description" diff --git a/tests/unit/team_agent/team_agent_test.py b/tests/unit/team_agent/team_agent_test.py index 5a154d0b..c115a86a 100644 --- a/tests/unit/team_agent/team_agent_test.py +++ b/tests/unit/team_agent/team_agent_test.py @@ -160,7 +160,7 @@ def test_create_team_agent(mock_model_factory_get): "id": "123", "name": "Test Agent(-)", "description": "Test Agent Description", - "role": "Test Agent Role", + "instructions": "Test Agent Instructions", "teamId": "123", "version": "1.0", "status": "onboarded",