From 4a112abc7f96ee4d890aa1fa4b655b216a3282ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20G=C3=BCnd=C3=BCz?= Date: Tue, 12 Aug 2025 13:01:14 +0300 Subject: [PATCH] Revert "changed all role to instructions (#602)" This reverts commit 77aac736ec20617dfcd7f97f366c2b0cd0ed611a. --- aixplain/factories/agent_factory/__init__.py | 4 +-- aixplain/factories/agent_factory/utils.py | 2 +- .../factories/team_agent_factory/__init__.py | 3 +-- .../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(+), 23 deletions(-) diff --git a/aixplain/factories/agent_factory/__init__.py b/aixplain/factories/agent_factory/__init__.py index 2fac114c..c952cef3 100644 --- a/aixplain/factories/agent_factory/__init__.py +++ b/aixplain/factories/agent_factory/__init__.py @@ -75,7 +75,7 @@ def create( Args: name (Text): name of the agent description (Text): description of the agent role. - instructions (Text): instructions of the agent. + instructions (Text): role 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 []. @@ -122,7 +122,7 @@ def create( "name": name, "assets": [build_tool_payload(tool) for tool in tools], "description": description, - "instructions": instructions or description, + "role": 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 307c113e..0f232dbd 100644 --- a/aixplain/factories/agent_factory/utils.py +++ b/aixplain/factories/agent_factory/utils.py @@ -178,7 +178,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("instructions"), + instructions=payload.get("role"), 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 ef5a6225..5022533e 100644 --- a/aixplain/factories/team_agent_factory/__init__.py +++ b/aixplain/factories/team_agent_factory/__init__.py @@ -193,9 +193,8 @@ def _setup_llm_and_tool(llm_param: Optional[Union[LLM, Text]], "supplier": supplier, "version": version, "status": "draft", - "tools": [], - "instructions": instructions, "tools": tools, + "role": instructions, } # Store the LLM objects directly in the payload for build_team_agent internal_payload = payload.copy() diff --git a/aixplain/factories/team_agent_factory/utils.py b/aixplain/factories/team_agent_factory/utils.py index de34b428..d0b6557f 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("instructions", None), + instructions=payload.get("role", 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 b1dea3a2..5e456026 100644 --- a/aixplain/modules/agent/__init__.py +++ b/aixplain/modules/agent/__init__.py @@ -446,7 +446,7 @@ def to_dict(self) -> Dict: "name": self.name, "assets": [build_tool_payload(tool) for tool in self.tools], "description": self.description, - "instructions": self.instructions or self.description, + "role": 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 9d89d63b..f818f278 100644 --- a/aixplain/modules/team_agent/__init__.py +++ b/aixplain/modules/team_agent/__init__.py @@ -443,7 +443,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, - "instructions": self.instructions, + "role": self.instructions, "outputFormat": self.output_format.value, "expectedOutput": self.expected_output, } diff --git a/tests/unit/agent/agent_factory_utils_test.py b/tests/unit/agent/agent_factory_utils_test.py index 5c7fbb77..59486242 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", - "instructions": "Test Instructions", + "role": "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 845f2b91..5a930c96 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", - "instructions": "Test Agent Instruction", + "role": "Test Agent Role", "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["instructions"] + assert agent.instructions == ref_response["role"] 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["instructions"] == "Test Agent Instructions" + assert agent_json["role"] == "Test Agent Role" 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", - "instructions": "Test Agent Instructions", + "role": "Test Agent Role", "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["instructions"] + assert agent.instructions == ref_response["role"] 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", - "instructions": "Test Agent Instructions", + "role": "Test Agent Role", "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["instructions"] + assert agent.instructions == ref_response["role"] 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", - "instructions": "Test Agent Description", # Should fallback to description + "role": "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["instructions"] == "Test Agent Description" + assert sent_payload["role"] == "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["instructions"] == "Test Description" # Should fallback to description + assert payload["role"] == "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["instructions"] == "Custom Instructions" + assert payload["role"] == "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", - "instructions": "Test Agent Description", # Should fallback to description + "role": "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["instructions"] == "Test Agent Description" + assert sent_payload["role"] == "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 afe08f1f..e98307cf 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", - "instructions": "Test Agent Instructions", + "role": "Test Agent Role", "teamId": "123", "version": "1.0", "status": "onboarded",