Update inner tool usage logic to support both regular and function calling

This commit is contained in:
João Moura
2024-03-02 13:54:23 -03:00
parent c523fcdaab
commit 8468445e1d
10 changed files with 208 additions and 142 deletions

View File

@@ -25,16 +25,15 @@ class Task(BaseModel):
i18n: I18N = I18N()
thread: threading.Thread = None
description: str = Field(description="Description of the actual task.")
expected_output: str = Field(
description="Clear definition of expected output for the task."
)
callback: Optional[Any] = Field(
description="Callback to be executed after the task is completed.", default=None
)
agent: Optional[Agent] = Field(
description="Agent responsible for execution the task.", default=None
)
expected_output: Optional[str] = Field(
description="Clear definition of expected output for the task.",
default=None,
)
context: Optional[List["Task"]] = Field(
description="Other tasks that will have their output used as context for this task.",
default=None,
@@ -166,19 +165,17 @@ class Task(BaseModel):
"""
tasks_slices = [self.description]
if self.expected_output:
output = self.i18n.slice("expected_output").format(
expected_output=self.expected_output
)
tasks_slices = [self.description, output]
output = self.i18n.slice("expected_output").format(
expected_output=self.expected_output
)
tasks_slices = [self.description, output]
return "\n".join(tasks_slices)
def interpolate_inputs(self, inputs: Dict[str, Any]) -> None:
"""Interpolate inputs into the task description and expected output."""
if inputs:
self.description = self.description.format(**inputs)
if self.expected_output:
self.expected_output = self.expected_output.format(**inputs)
self.expected_output = self.expected_output.format(**inputs)
def increment_tools_errors(self) -> None:
"""Increment the tools errors counter."""