diff --git a/aixplain/factories/agent_factory/__init__.py b/aixplain/factories/agent_factory/__init__.py index c952cef3..2fac114c 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): 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 []. @@ -122,7 +122,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 0f232dbd..307c113e 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("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 5022533e..ef5a6225 100644 --- a/aixplain/factories/team_agent_factory/__init__.py +++ b/aixplain/factories/team_agent_factory/__init__.py @@ -193,8 +193,9 @@ 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 d0b6557f..de34b428 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 5e456026..b1dea3a2 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, - "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 f818f278..9d89d63b 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, - "role": self.instructions, + "instructions": 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 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 5a930c96..845f2b91 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 e98307cf..afe08f1f 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",