From d37a21af24103a74d3a5814724262c4b0eef1dca Mon Sep 17 00:00:00 2001 From: Ayo Ayibiowu Date: Mon, 9 Dec 2024 11:00:14 +0100 Subject: [PATCH] fix(tools): address issue using args --- examples/agents/impact_assessment_crew.yaml | 4 +++- sage/validators/crew_ai.py | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/agents/impact_assessment_crew.yaml b/examples/agents/impact_assessment_crew.yaml index ef8ce00..252464a 100644 --- a/examples/agents/impact_assessment_crew.yaml +++ b/examples/agents/impact_assessment_crew.yaml @@ -12,7 +12,9 @@ agents: goal: Retrieve all data about the merge request for further processing from the GitLab API backstory: An adept communicator with GitLab, retrieving and presenting all information efficiently. tools: - - GitlabMergeRequestTool + - name: GitlabMergeRequestTool + args: + result_as_answer: true - role: Content Analysis Agent goal: Categorize the changed files (e.g., code, documentation, configuration, assets) and assign an impact score based on content type significance on a scale from 0 to 10. diff --git a/sage/validators/crew_ai.py b/sage/validators/crew_ai.py index dfa73dd..4a1d507 100644 --- a/sage/validators/crew_ai.py +++ b/sage/validators/crew_ai.py @@ -21,7 +21,7 @@ class ToolsConfig(BaseModel): """ToolsConfig model""" name: str - args: Optional[dict[str, Any]] = None + args: dict[str, Any] = {} class TaskConfig(Task): @@ -34,7 +34,7 @@ class AgentConfig(Agent): allow_delegation: bool = Field( default=False, description="Allow delegation of tasks to agents" ) - tools: Optional[List[ToolsConfig | BaseTool | str | dict]] = Field( + tools: Optional[List[ToolsConfig | BaseTool | str ]] = Field( default_factory=list, description="Tools at agents' disposal" ) @@ -76,9 +76,9 @@ def validate_tools(cls, tools: list): if isinstance(tool_entry, str): tool_name = tool_entry tool_args = {} - elif isinstance(tool_entry, dict): - tool_name = tool_entry.get("name") - tool_args = tool_entry.get("args", {}) + elif isinstance(tool_entry, ToolsConfig): + tool_name = tool_entry.name + tool_args = tool_entry.args else: raise ValueError(f"Invalid tool format: {tool_entry}")