adding support for input interpolation for tasks and agents

This commit is contained in:
João Moura
2024-02-28 02:59:58 -03:00
parent 2530196cf8
commit 997c906b5f
4 changed files with 49 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
import os
import uuid
from typing import Any, List, Optional, Tuple
from typing import Any, Dict, List, Optional, Tuple
from crewai_tools import BaseTool as CrewAITool
from langchain.agents.agent import RunnableAgent
@@ -255,6 +255,12 @@ class Agent(BaseModel):
agent=RunnableAgent(runnable=inner_agent), **executor_args
)
def interpolate_inputs(self, inputs: Dict[str, Any]) -> None:
"""Interpolate inputs into the agent description and backstory."""
self.role = self.role.format(**inputs)
self.goal = self.goal.format(**inputs)
self.backstory = self.backstory.format(**inputs)
def increment_formatting_errors(self) -> None:
"""Count the formatting errors of the agent."""
self.formatting_errors += 1