mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 16:18:30 +00:00
counting for tool retries on the acutal usage
This commit is contained in:
@@ -60,9 +60,10 @@ class ToolUsage:
|
||||
self._printer.print(content=f"\n\n{error}\n", color="yellow")
|
||||
return error
|
||||
tool = self._select_tool(calling.function_name)
|
||||
return self._use(tool=tool, calling=calling)
|
||||
return self._use(tool_string=tool_string, tool=tool, calling=calling)
|
||||
|
||||
def _use(self, tool: BaseTool, calling: ToolCalling) -> None:
|
||||
def _use(self, tool_string: str, tool: BaseTool, calling: ToolCalling) -> None:
|
||||
try:
|
||||
if self._check_tool_repeated_usage(calling=calling):
|
||||
result = self._i18n.errors("task_repeated_usage").format(
|
||||
tool=calling.function_name, tool_input=calling.arguments
|
||||
@@ -85,6 +86,14 @@ class ToolUsage:
|
||||
|
||||
result = self._format_result(result=result)
|
||||
return result
|
||||
except Exception:
|
||||
self._run_attempts += 1
|
||||
if self._run_attempts > self._max_parsing_attempts:
|
||||
self._telemetry.tool_usage_error(llm=self.llm)
|
||||
return ToolUsageErrorException(
|
||||
self._i18n.errors("tool_usage_error")
|
||||
).message
|
||||
return self.use(tool_string=tool_string)
|
||||
|
||||
def _format_result(self, result: Any) -> None:
|
||||
self.task.used_tools += 1
|
||||
|
||||
Reference in New Issue
Block a user