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
15 changes: 2 additions & 13 deletions aixplain/factories/agent_factory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@
from aixplain.enums import DatabaseSourceType


def to_literal_text(x):
"""Convert value to literal text, escaping braces for string formatting.

Args:
x: Value to convert (dict, list, or any other type)

Returns:
str: Escaped string representation
"""
s = json.dumps(x, ensure_ascii=False, indent=2) if isinstance(x, (dict, list)) else str(x)
return s.replace("{", "{{").replace("}", "}}")


class AgentFactory:
Expand Down Expand Up @@ -157,8 +146,8 @@ def create(
payload = {
"name": name,
"assets": [build_tool_payload(tool) for tool in tools],
"description": to_literal_text(description),
"instructions": to_literal_text(instructions) if instructions is not None else description,
"description": description,
"instructions": instructions if instructions is not None else description,
"supplier": supplier,
"version": version,
"llmId": llm_id,
Expand Down
14 changes: 4 additions & 10 deletions aixplain/modules/agent/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,10 @@ def process_variables(

variables = re.findall(r"(?<!{){([^}]+)}(?!})", agent_description or "")
for variable in variables:
if isinstance(data, dict):
assert (
variable in data or variable in parameters
), f"Variable '{variable}' not found in data or parameters. This variable is required by the agent according to its description ('{agent_description}')."
input_data[variable] = data.pop(variable) if variable in data else parameters.pop(variable)
else:
assert (
variable in parameters
), f"Variable '{variable}' not found in parameters. This variable is required by the agent according to its description ('{agent_description}')."
input_data[variable] = parameters.pop(variable)
if isinstance(data, dict) and variable in data:
input_data[variable] = data[variable]
elif variable in parameters:
input_data[variable] = parameters[variable]

return input_data

Expand Down
7 changes: 4 additions & 3 deletions tests/functional/team_agent/team_agent_functional_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test_add_remove_agents_from_team_agent(run_input_map, delete_agents_and_team
def test_team_agent_tasks(delete_agents_and_team_agents):
assert delete_agents_and_team_agents
agent = AgentFactory.create(
name="Teste",
name="Test Sub Agent",
description="You are a test agent that always returns the same answer",
tools=[
AgentFactory.create_model_tool(function=Function.TRANSLATION, supplier=Supplier.MICROSOFT),
Expand All @@ -268,13 +268,13 @@ def test_team_agent_tasks(delete_agents_and_team_agents):
)

team_agent = TeamAgentFactory.create(
name="Teste",
name="Test Multi Agent",
agents=[agent],
description="Teste",
)
response = team_agent.run(data="Translate 'teste'")
assert response.status == "SUCCESS"
assert "teste" in response.data["output"]
assert "test" in response.data["output"]


def test_team_agent_with_parameterized_agents(run_input_map, delete_agents_and_team_agents):
Expand Down Expand Up @@ -538,6 +538,7 @@ def test_team_agent_with_slack_connector():
authentication_schema=AuthenticationSchema.BEARER_TOKEN,
data={"token": os.getenv("SLACK_TOKEN")},
)

connection_id = response.data["id"]

connection = ModelFactory.get(connection_id)
Expand Down