Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aixplain/factories/agent_factory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [].
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion aixplain/factories/agent_factory/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 2 additions & 1 deletion aixplain/factories/team_agent_factory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion aixplain/factories/team_agent_factory/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion aixplain/modules/agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion aixplain/modules/team_agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/agent/agent_factory_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 13 additions & 13 deletions tests/unit/agent/agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"]

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"]

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"


Expand All @@ -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

Expand All @@ -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"

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/team_agent/team_agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down