mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-26 00:28:13 +00:00
TYPO
This commit is contained in:
@@ -97,7 +97,7 @@ class ToolUsage:
|
|||||||
self.task.increment_tools_errors()
|
self.task.increment_tools_errors()
|
||||||
self._printer.print(content=f"\n\n{error}\n", color="red")
|
self._printer.print(content=f"\n\n{error}\n", color="red")
|
||||||
return error
|
return error
|
||||||
return f"{self._use(tool_string=tool_string, tool=tool, calling=calling)}" # type: ignore # BUG?: "_use" of "ToolUsage" does not return a value (it only ever returns None)
|
return f"{self._use(tool_string=tool_string, tool=tool, calling=calling)}" # type: ignore # BUG?: "_use" of "ToolUsage" does not return a value (it only ever returns None)
|
||||||
|
|
||||||
def _use(
|
def _use(
|
||||||
self,
|
self,
|
||||||
@@ -105,8 +105,8 @@ class ToolUsage:
|
|||||||
tool: BaseTool,
|
tool: BaseTool,
|
||||||
calling: Union[ToolCalling, InstructorToolCalling],
|
calling: Union[ToolCalling, InstructorToolCalling],
|
||||||
) -> str: # TODO: Fix this return type
|
) -> str: # TODO: Fix this return type
|
||||||
tool_event = agentops.ToolEvent(name=calling.tool_name) if agentops else None
|
tool_event = agentops.ToolEvent(name=calling.tool_name) if agentops else None
|
||||||
if self._check_tool_repeated_usage(calling=calling): # type: ignore # _check_tool_repeated_usage of "ToolUsage" does not return a value (it only ever returns None)
|
if self._check_tool_repeated_usage(calling=calling): # type: ignore # _check_tool_repeated_usage of "ToolUsage" does not return a value (it only ever returns None)
|
||||||
try:
|
try:
|
||||||
result = self._i18n.errors("task_repeated_usage").format(
|
result = self._i18n.errors("task_repeated_usage").format(
|
||||||
tool_names=self.tools_names
|
tool_names=self.tools_names
|
||||||
@@ -117,20 +117,20 @@ class ToolUsage:
|
|||||||
tool_name=tool.name,
|
tool_name=tool.name,
|
||||||
attempts=self._run_attempts,
|
attempts=self._run_attempts,
|
||||||
)
|
)
|
||||||
result = self._format_result(result=result) # type: ignore # "_format_result" of "ToolUsage" does not return a value (it only ever returns None)
|
result = self._format_result(result=result) # type: ignore # "_format_result" of "ToolUsage" does not return a value (it only ever returns None)
|
||||||
return result # type: ignore # Fix the reutrn type of this function
|
return result # type: ignore # Fix the reutrn type of this function
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self.task.increment_tools_errors()
|
self.task.increment_tools_errors()
|
||||||
|
|
||||||
result = None # type: ignore # Incompatible types in assignment (expression has type "None", variable has type "str")
|
result = None # type: ignore # Incompatible types in assignment (expression has type "None", variable has type "str")
|
||||||
|
|
||||||
if self.tools_handler.cache:
|
if self.tools_handler.cache:
|
||||||
result = self.tools_handler.cache.read( # type: ignore # Incompatible types in assignment (expression has type "str | None", variable has type "str")
|
result = self.tools_handler.cache.read( # type: ignore # Incompatible types in assignment (expression has type "str | None", variable has type "str")
|
||||||
tool=calling.tool_name, input=calling.arguments
|
tool=calling.tool_name, input=calling.arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
if result is None: #! finecwg: if not result --> if result is None
|
if result is None: #! finecwg: if not result --> if result is None
|
||||||
try:
|
try:
|
||||||
if calling.tool_name in [
|
if calling.tool_name in [
|
||||||
"Delegate work to coworker",
|
"Delegate work to coworker",
|
||||||
@@ -140,7 +140,7 @@ class ToolUsage:
|
|||||||
|
|
||||||
if calling.arguments:
|
if calling.arguments:
|
||||||
try:
|
try:
|
||||||
acceptable_args = tool.args_schema.schema()["properties"].keys() # type: ignore # Item "None" of "type[BaseModel] | None" has no attribute "schema"
|
acceptable_args = tool.args_schema.schema()["properties"].keys() # type: ignore # Item "None" of "type[BaseModel] | None" has no attribute "schema"
|
||||||
arguments = {
|
arguments = {
|
||||||
k: v
|
k: v
|
||||||
for k, v in calling.arguments.items()
|
for k, v in calling.arguments.items()
|
||||||
@@ -152,7 +152,7 @@ class ToolUsage:
|
|||||||
arguments = calling.arguments
|
arguments = calling.arguments
|
||||||
result = tool._run(**arguments)
|
result = tool._run(**arguments)
|
||||||
else:
|
else:
|
||||||
arguments = calling.arguments.values() # type: ignore # Incompatible types in assignment (expression has type "dict_values[str, Any]", variable has type "dict[str, Any]")
|
arguments = calling.arguments.values() # type: ignore # Incompatible types in assignment (expression has type "dict_values[str, Any]", variable has type "dict[str, Any]")
|
||||||
result = tool._run(*arguments)
|
result = tool._run(*arguments)
|
||||||
else:
|
else:
|
||||||
result = tool._run()
|
result = tool._run()
|
||||||
@@ -201,14 +201,14 @@ class ToolUsage:
|
|||||||
llm=self.function_calling_llm,
|
llm=self.function_calling_llm,
|
||||||
tool_name=tool.name,
|
tool_name=tool.name,
|
||||||
attempts=self._run_attempts,
|
attempts=self._run_attempts,
|
||||||
)
|
)
|
||||||
result = self._format_result(result=result) # type: ignore # "_format_result" of "ToolUsage" does not return a value (it only ever returns None)
|
result = self._format_result(result=result) # type: ignore # "_format_result" of "ToolUsage" does not return a value (it only ever returns None)
|
||||||
return result # type: ignore # No return value expected
|
return result # type: ignore # No return value expected
|
||||||
|
|
||||||
def _format_result(self, result: Any) -> None:
|
def _format_result(self, result: Any) -> None:
|
||||||
self.task.used_tools += 1
|
self.task.used_tools += 1
|
||||||
if self._should_remember_format(): # type: ignore # "_should_remember_format" of "ToolUsage" does not return a value (it only ever returns None)
|
if self._should_remember_format(): # type: ignore # "_should_remember_format" of "ToolUsage" does not return a value (it only ever returns None)
|
||||||
result = self._remember_format(result=result) # type: ignore # "_remember_format" of "ToolUsage" does not return a value (it only ever returns None)
|
result = self._remember_format(result=result) # type: ignore # "_remember_format" of "ToolUsage" does not return a value (it only ever returns None)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _should_remember_format(self) -> None:
|
def _should_remember_format(self) -> None:
|
||||||
@@ -303,7 +303,7 @@ class ToolUsage:
|
|||||||
Example:
|
Example:
|
||||||
{"tool_name": "tool name", "arguments": {"arg_name1": "value", "arg_name2": 2}}""",
|
{"tool_name": "tool name", "arguments": {"arg_name1": "value", "arg_name2": 2}}""",
|
||||||
),
|
),
|
||||||
max_attemps=1,
|
max_attempts=1,
|
||||||
)
|
)
|
||||||
calling = converter.to_pydantic()
|
calling = converter.to_pydantic()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user