From 16cdabbf3513abc2333c595cf67996ab0f25a13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moura?= Date: Fri, 3 Jan 2025 02:53:24 -0300 Subject: [PATCH] bumping verison fixing tests --- .../browserbase_load_tool.py | 2 +- tests/base_tool_test.py | 19 ++++++++++--------- tests/spider_tool_test.py | 12 ++++++------ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/crewai_tools/tools/browserbase_load_tool/browserbase_load_tool.py b/src/crewai_tools/tools/browserbase_load_tool/browserbase_load_tool.py index 95e4084fd..2ca1b95fc 100644 --- a/src/crewai_tools/tools/browserbase_load_tool/browserbase_load_tool.py +++ b/src/crewai_tools/tools/browserbase_load_tool/browserbase_load_tool.py @@ -2,7 +2,7 @@ import os from typing import Any, Optional, Type from pydantic import BaseModel, Field -from crewai_tools.tools.base_tool import BaseTool +from crewai.tools import BaseTool class BrowserbaseLoadToolSchema(BaseModel): diff --git a/tests/base_tool_test.py b/tests/base_tool_test.py index 949a445c2..4a4e40783 100644 --- a/tests/base_tool_test.py +++ b/tests/base_tool_test.py @@ -1,5 +1,6 @@ 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(): @tool("Name of my tool") @@ -9,14 +10,14 @@ def test_creating_a_tool_using_annotation(): # Assert all the right attributes were defined 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.func("What is the meaning of life?") == "What is the meaning of life?" # 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.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.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() # Assert all the right attributes were defined 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.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 - converted_tool = my_tool.to_langchain() + converted_tool = to_langchain([my_tool])[0] 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.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(): class MyCustomTool(BaseTool): diff --git a/tests/spider_tool_test.py b/tests/spider_tool_test.py index 977dd8769..264394777 100644 --- a/tests/spider_tool_test.py +++ b/tests/spider_tool_test.py @@ -3,7 +3,7 @@ from crewai import Agent, Task, Crew def test_spider_tool(): spider_tool = SpiderTool() - + searcher = Agent( role="Web Research Expert", goal="Find related information from specific URL's", @@ -12,7 +12,7 @@ def test_spider_tool(): verbose=True, cache=False ) - + choose_between_scrape_crawl = Task( description="Scrape the page of spider.cloud and return a summary of how fast it is", expected_output="spider.cloud is a fast scraping and crawling tool", @@ -34,13 +34,13 @@ def test_spider_tool(): crew = Crew( agents=[searcher], tasks=[ - choose_between_scrape_crawl, - return_metadata, + choose_between_scrape_crawl, + return_metadata, css_selector ], - verbose=2 + verbose=True ) - + crew.kickoff() if __name__ == "__main__":