mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-27 00:58:13 +00:00
bumping verison fixing tests
This commit is contained in:
@@ -2,7 +2,7 @@ import os
|
|||||||
from typing import Any, Optional, Type
|
from typing import Any, Optional, Type
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from crewai_tools.tools.base_tool import BaseTool
|
from crewai.tools import BaseTool
|
||||||
|
|
||||||
|
|
||||||
class BrowserbaseLoadToolSchema(BaseModel):
|
class BrowserbaseLoadToolSchema(BaseModel):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from typing import Callable
|
from typing import Callable
|
||||||
from crewai_tools import BaseTool, tool
|
from crewai.tools import BaseTool, tool
|
||||||
|
from crewai.tools.base_tool import to_langchain
|
||||||
|
|
||||||
def test_creating_a_tool_using_annotation():
|
def test_creating_a_tool_using_annotation():
|
||||||
@tool("Name of my tool")
|
@tool("Name of my tool")
|
||||||
@@ -9,14 +10,14 @@ def test_creating_a_tool_using_annotation():
|
|||||||
|
|
||||||
# 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 my_tool.description == "Name of my tool(question: 'string') - Clear description for what this tool is useful for, you agent will need this information to use it."
|
assert 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."
|
||||||
assert my_tool.args_schema.schema()["properties"] == {'question': {'title': 'Question', 'type': 'string'}}
|
assert my_tool.args_schema.schema()["properties"] == {'question': {'title': 'Question', 'type': 'string'}}
|
||||||
assert my_tool.func("What is the meaning of life?") == "What is the meaning of life?"
|
assert my_tool.func("What is the meaning of life?") == "What is the meaning of life?"
|
||||||
|
|
||||||
# Assert the langchain tool conversion worked as expected
|
# Assert the langchain tool conversion worked as expected
|
||||||
converted_tool = my_tool.to_langchain()
|
converted_tool = to_langchain([my_tool])[0]
|
||||||
assert converted_tool.name == "Name of my tool"
|
assert converted_tool.name == "Name of my tool"
|
||||||
assert converted_tool.description == "Name of my tool(question: 'string') - Clear description for what this tool is useful for, you agent will need this information to use it."
|
assert 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."
|
||||||
assert converted_tool.args_schema.schema()["properties"] == {'question': {'title': 'Question', 'type': 'string'}}
|
assert converted_tool.args_schema.schema()["properties"] == {'question': {'title': 'Question', 'type': 'string'}}
|
||||||
assert converted_tool.func("What is the meaning of life?") == "What is the meaning of life?"
|
assert converted_tool.func("What is the meaning of life?") == "What is the meaning of life?"
|
||||||
|
|
||||||
@@ -31,16 +32,16 @@ def test_creating_a_tool_using_baseclass():
|
|||||||
my_tool = MyCustomTool()
|
my_tool = MyCustomTool()
|
||||||
# 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 my_tool.description == "Name of my tool(question: 'string') - Clear description for what this tool is useful for, you agent will need this information to use it."
|
assert 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."
|
||||||
assert my_tool.args_schema.schema()["properties"] == {'question': {'title': 'Question', 'type': 'string'}}
|
assert my_tool.args_schema.schema()["properties"] == {'question': {'title': 'Question', 'type': 'string'}}
|
||||||
assert my_tool.run("What is the meaning of life?") == "What is the meaning of life?"
|
assert my_tool._run("What is the meaning of life?") == "What is the meaning of life?"
|
||||||
|
|
||||||
# Assert the langchain tool conversion worked as expected
|
# Assert the langchain tool conversion worked as expected
|
||||||
converted_tool = my_tool.to_langchain()
|
converted_tool = to_langchain([my_tool])[0]
|
||||||
assert converted_tool.name == "Name of my tool"
|
assert converted_tool.name == "Name of my tool"
|
||||||
assert converted_tool.description == "Name of my tool(question: 'string') - Clear description for what this tool is useful for, you agent will need this information to use it."
|
assert 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."
|
||||||
assert converted_tool.args_schema.schema()["properties"] == {'question': {'title': 'Question', 'type': 'string'}}
|
assert converted_tool.args_schema.schema()["properties"] == {'question': {'title': 'Question', 'type': 'string'}}
|
||||||
assert converted_tool.run("What is the meaning of life?") == "What is the meaning of life?"
|
assert converted_tool.invoke({"question": "What is the meaning of life?"}) == "What is the meaning of life?"
|
||||||
|
|
||||||
def test_setting_cache_function():
|
def test_setting_cache_function():
|
||||||
class MyCustomTool(BaseTool):
|
class MyCustomTool(BaseTool):
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ def test_spider_tool():
|
|||||||
return_metadata,
|
return_metadata,
|
||||||
css_selector
|
css_selector
|
||||||
],
|
],
|
||||||
verbose=2
|
verbose=True
|
||||||
)
|
)
|
||||||
|
|
||||||
crew.kickoff()
|
crew.kickoff()
|
||||||
|
|||||||
Reference in New Issue
Block a user