Fix small typo in sample tool (#1747)

Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com>
This commit is contained in:
André Lago
2024-12-12 15:11:47 +00:00
committed by GitHub
parent bc5e303d5f
commit 8094754239
3 changed files with 10 additions and 10 deletions

View File

@@ -10,7 +10,7 @@ class MyCustomToolInput(BaseModel):
class MyCustomTool(BaseTool): class MyCustomTool(BaseTool):
name: str = "Name of my tool" name: str = "Name of my tool"
description: str = ( description: str = (
"Clear description for what this tool is useful for, you agent will need this information to use it." "Clear description for what this tool is useful for, your agent will need this information to use it."
) )
args_schema: Type[BaseModel] = MyCustomToolInput args_schema: Type[BaseModel] = MyCustomToolInput

View File

@@ -13,7 +13,7 @@ class MyCustomToolInput(BaseModel):
class MyCustomTool(BaseTool): class MyCustomTool(BaseTool):
name: str = "Name of my tool" name: str = "Name of my tool"
description: str = ( description: str = (
"Clear description for what this tool is useful for, you agent will need this information to use it." "Clear description for what this tool is useful for, your agent will need this information to use it."
) )
args_schema: Type[BaseModel] = MyCustomToolInput args_schema: Type[BaseModel] = MyCustomToolInput

View File

@@ -6,14 +6,14 @@ from crewai.tools import BaseTool, tool
def test_creating_a_tool_using_annotation(): def test_creating_a_tool_using_annotation():
@tool("Name of my tool") @tool("Name of my tool")
def my_tool(question: str) -> str: def my_tool(question: str) -> str:
"""Clear description for what this tool is useful for, you agent will need this information to use it.""" """Clear description for what this tool is useful for, your agent will need this information to use it."""
return question return question
# Assert all the right attributes were defined # Assert all the right attributes were defined
assert my_tool.name == "Name of my tool" assert my_tool.name == "Name of my tool"
assert ( assert (
my_tool.description my_tool.description
== "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, you agent will need this information to use it." == "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, your agent will need this information to use it."
) )
assert my_tool.args_schema.schema()["properties"] == { assert my_tool.args_schema.schema()["properties"] == {
"question": {"title": "Question", "type": "string"} "question": {"title": "Question", "type": "string"}
@@ -27,7 +27,7 @@ def test_creating_a_tool_using_annotation():
assert ( assert (
converted_tool.description converted_tool.description
== "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, you agent will need this information to use it." == "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, your agent will need this information to use it."
) )
assert converted_tool.args_schema.schema()["properties"] == { assert converted_tool.args_schema.schema()["properties"] == {
"question": {"title": "Question", "type": "string"} "question": {"title": "Question", "type": "string"}
@@ -41,7 +41,7 @@ def test_creating_a_tool_using_annotation():
def test_creating_a_tool_using_baseclass(): def test_creating_a_tool_using_baseclass():
class MyCustomTool(BaseTool): class MyCustomTool(BaseTool):
name: str = "Name of my tool" name: str = "Name of my tool"
description: str = "Clear description for what this tool is useful for, you agent will need this information to use it." description: str = "Clear description for what this tool is useful for, your agent will need this information to use it."
def _run(self, question: str) -> str: def _run(self, question: str) -> str:
return question return question
@@ -52,7 +52,7 @@ def test_creating_a_tool_using_baseclass():
assert ( assert (
my_tool.description my_tool.description
== "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, you agent will need this information to use it." == "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, your agent will need this information to use it."
) )
assert my_tool.args_schema.schema()["properties"] == { assert my_tool.args_schema.schema()["properties"] == {
"question": {"title": "Question", "type": "string"} "question": {"title": "Question", "type": "string"}
@@ -64,7 +64,7 @@ def test_creating_a_tool_using_baseclass():
assert ( assert (
converted_tool.description converted_tool.description
== "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, you agent will need this information to use it." == "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, your agent will need this information to use it."
) )
assert converted_tool.args_schema.schema()["properties"] == { assert converted_tool.args_schema.schema()["properties"] == {
"question": {"title": "Question", "type": "string"} "question": {"title": "Question", "type": "string"}
@@ -78,7 +78,7 @@ def test_creating_a_tool_using_baseclass():
def test_setting_cache_function(): def test_setting_cache_function():
class MyCustomTool(BaseTool): class MyCustomTool(BaseTool):
name: str = "Name of my tool" name: str = "Name of my tool"
description: str = "Clear description for what this tool is useful for, you agent will need this information to use it." description: str = "Clear description for what this tool is useful for, your agent will need this information to use it."
cache_function: Callable = lambda: False cache_function: Callable = lambda: False
def _run(self, question: str) -> str: def _run(self, question: str) -> str:
@@ -92,7 +92,7 @@ def test_setting_cache_function():
def test_default_cache_function_is_true(): def test_default_cache_function_is_true():
class MyCustomTool(BaseTool): class MyCustomTool(BaseTool):
name: str = "Name of my tool" name: str = "Name of my tool"
description: str = "Clear description for what this tool is useful for, you agent will need this information to use it." description: str = "Clear description for what this tool is useful for, your agent will need this information to use it."
def _run(self, question: str) -> str: def _run(self, question: str) -> str:
return question return question