mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
improve tool text descriptoin and args
This commit is contained in:
@@ -393,30 +393,22 @@ class Agent(BaseAgent):
|
|||||||
return description
|
return description
|
||||||
|
|
||||||
def _render_text_description_and_args(self, tools: List[Any]) -> str:
|
def _render_text_description_and_args(self, tools: List[Any]) -> str:
|
||||||
"""Render the tool name, description, and args in plain text.
|
|
||||||
|
|
||||||
Output will be in the format of:
|
|
||||||
|
|
||||||
.. code-block:: markdown
|
|
||||||
|
|
||||||
search: This tool is used for search, args: {"query": {"type": "string"}}
|
|
||||||
calculator: This tool is used for math, \
|
|
||||||
args: {"expression": {"type": "string"}}
|
|
||||||
"""
|
|
||||||
tool_strings = []
|
tool_strings = []
|
||||||
for tool in tools:
|
for tool in tools:
|
||||||
args_schema = str(tool.model_fields)
|
args_schema = {
|
||||||
if hasattr(tool, "func") and tool.func:
|
name: {
|
||||||
sig = signature(tool.func)
|
"description": field.description,
|
||||||
description = (
|
"type": field.annotation.__name__,
|
||||||
f"Tool Name: {tool.name}{sig}\nTool Description: {tool.description}"
|
}
|
||||||
)
|
for name, field in tool.args_schema.model_fields.items()
|
||||||
else:
|
}
|
||||||
description = (
|
description = (
|
||||||
f"Tool Name: {tool.name}\nTool Description: {tool.description}"
|
f"Tool Name: {tool.name}\nTool Description: {tool.description}"
|
||||||
)
|
)
|
||||||
tool_strings.append(f"{description}\nTool Arguments: {args_schema}")
|
tool_strings.append(f"{description}\nTool Arguments: {args_schema}")
|
||||||
|
|
||||||
|
print("TOOL STRINGS:", "\n".join(tool_strings))
|
||||||
|
|
||||||
return "\n".join(tool_strings)
|
return "\n".join(tool_strings)
|
||||||
|
|
||||||
def _validate_docker_installation(self) -> None:
|
def _validate_docker_installation(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user