DuckDuckGo Search not working anymore? Not supported?
I updated to the latest crewai release 0.19.0 and DuckDuckGo Search does not working anymore. Is this not supported anymore? Here is the error:
`Action: duckduckgo_search Action Input: {"q": "AIi news latest not older than 1 day"}
I encountered an error while trying to use the tool. This was the error: DuckDuckGoSearchRun._run() got an unexpected keyword argument 'q'. Tool duckduckgo_search accepts there inputs: A wrapper around DuckDuckGo Search. Useful for when you need to answer questions about current events. Input should be a search query. `
Hi, I have the same issue with error msg --> action duck_search doesn't exist
It seems to be something around how the duckduckgo tool specificaly was constructed, if you wrap it as a crewAI tool it shoudl work:
from crewai_tools import tool
@tool('DuckDuckGoSearch')
def search(search_query: str):
"""Search the web for information on a given topic"""
return DuckDuckGoSearchRun().run(search_query)
agent = Agent(
#...
tools=[search],
#...
)
-- João Moura @joaomdmoura http://twitter.com/joaomdmoura
Em ter., 5 de mar. de 2024 às 13:18, marioz78 @.***> escreveu:
Hi, I have the same issue with error msg --> action duck_search doesn't exist
— Reply to this email directly, view it on GitHub https://github.com/joaomdmoura/crewAI/issues/316#issuecomment-1979142855, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFC3N5Q27IV25FAZSUKKCDYWXV3TAVCNFSM6AAAAABEGYI526VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZZGE2DEOBVGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thx, tried your suggestions and also follow this
but I am getting this error:
ImportError: cannot import name 'tool' from 'crewai.tools' (/home/pi5/social/.venv/lib/python3.11/site-packages/crewai/tools/__init__.py)
can we get a DuckDuck tool in the crew_tools?
Think it should be _ in the from
from crewai_tools import ( DirectoryReadTool, FileReadTool, SerperDevTool, WebsiteSearchTool
In the same file where I have the Agents which call the search tool I have the following:
`from crewai_tools import tool from langchain_community.tools import DuckDuckGoSearchRun
search_query = "AI news"
@tool('DuckDuckGoSearch') def SearchDuck(search_query: str): """Search the web for information on a given topic""" return DuckDuckGoSearchRun().run(search_query)
search_tool = SearchDuck(search_query)`
This is the error now:
Traceback (most recent call last):
File "/home/pi5/social/main.py", line 60, in <module>
search_tool = SearchDuck(search_query)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'Tool' object is not callable
Am I missing something? It's basically the same as the docs!
It seems to be something around how the duckduckgo tool specificaly was constructed, if you wrap it as a crewAI tool it shoudl work:
python from crewai_tools import tool @tool('DuckDuckGoSearch') def search(search_query: str): """Search the web for information on a given topic""" return DuckDuckGoSearchRun().run(search_query) agent = Agent( #... tools=[search], #... )… -- João Moura @joaomdmoura http://twitter.com/joaomdmoura Em ter., 5 de mar. de 2024 às 13:18, marioz78 @.> escreveu: Hi, I have the same issue with error msg --> action duck_search doesn't exist — Reply to this email directly, view it on GitHub <#316 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFC3N5Q27IV25FAZSUKKCDYWXV3TAVCNFSM6AAAAABEGYI526VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZZGE2DEOBVGU . You are receiving this because you are subscribed to this thread.Message ID: @.>
wrapping it as suggested got the same errore --> Action 'DuckDuckGoSearch('latest advancements in AI 2024')' don't exist, these are the only available Actions: DuckDuckGoSearch: DuckDuckGoSearch(search_query: 'string') - Search the web for information on a given topic
Hello guys, I was facing absolutely the same problem but after the solution suggested by João seems it finally worked
Libraries version:
crewai 0.19.0
crewai-tools 0.0.15
duckduckgo_search 5.0
The changed part:
Output:
Well, I just tested and same issue:
Traceback (most recent call last):
File "/home/pi5/social/shorts/main.py", line 62, in <module>
search_tool = SearchDuck(source_material)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'Tool' object is not callable
I have from langchain_community.tools import DuckDuckGoSearchRun and getting the error above.
If I use from langchain.tools import DuckDuckGoSearchRun I get the following error:
`/home/pi5/social/.venv/lib/python3.11/site-packages/langchain/tools/init.py:63: LangChainDeprecationWarning: Importing tools from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
from langchain_community.tools import DuckDuckGoSearchRun.
To install langchain-community run pip install -U langchain-community.
warnings.warn(
Traceback (most recent call last):
File "/home/pi5/social/shorts/main.py", line 62, in
I have the lates crewai and crewai_tools installed.
Ok so I am testing this code by itself:
`from crewai import Agent, Task, Crew, Process
#DuckDuckGo used to search the Internet #from langchain.tools import DuckDuckGoSearchRun from langchain_community.tools import DuckDuckGoSearchRun
source_material = "AI news"
from crewai_tools import tool
@tool('DuckDuckGoSearch') def SearchDuck(search_query: str): """Search the web for information on a given topic""" return DuckDuckGoSearchRun().run(search_query)
search_tool = SearchDuck(source_material)`
getting the same error:
Traceback (most recent call last):
File "/home/pi5/social/shorts/test.py", line 17, in <module>
search_tool = SearchDuck(source_material)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'Tool' object is not callable
So something is wrong with the crewai installation? I always did updates.
Update: Unistalled crewai and crewai_tools, re-installed and still same issue!
ok looks like I figure it out:
@tool('DuckDuckGoSearch')
def searchduck(source_material: str):
"""Search the web for information on a given topic"""
return DuckDuckGoSearchRun().run(source_material)
I was invoking this:
search_tool = searchduck(source_material)
instead it should just be invoked inside the agent.
thx everyone for the help!
Hello guys, I was facing absolutely the same problem but after the solution suggested by João seems it finally worked
Libraries version: crewai 0.19.0 crewai-tools 0.0.15 duckduckgo_search 5.0The changed part:
Output:
Hi, I've got the same env but still receive error. my code
import os from crewai import Agent, Task, Crew, Process
#os.environ["OPENAI_API_KEY"] = "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" #os.environ["OPENAI_MODEL_NAME"] = "gpt-3.5-turbo-instruct-0914" os.environ["OPENAI_API_BASE"] = "https://b1ee-34-118-243-245.ngrok-free.app/v1" os.environ["OPENAI_MODEL_NAME"] = "vicuna-7b-v1.5" os.environ["OPENAI_API_KEY"] = "NA"
from langchain_community.tools import DuckDuckGoSearchRun #search_tool = DuckDuckGoSearchRun()
from crewai_tools import tool
@tool('DuckDuckGoSearch') def search(search_query: str): """Search the web for information on a given topic""" return DuckDuckGoSearchRun().run(search_query)
Define your agents with roles and goals
researcher = Agent( role='Senior Research Analyst', goal='Uncover cutting-edge developments in AI and data science', backstory="""You work at a leading tech think tank. Your expertise lies in identifying emerging trends. You have a knack for dissecting complex data and presenting actionable insights.""", verbose=True, allow_delegation=False, tools=[search] )
@tool("Needfindertool")
def Need_tool(Company_name: str):
"""The input to this tool should be the name of the client company they are searching for ,
This tool is useful for finding the core needs of given company
"""
loader = CSVLoader(file_path="client.csv")
texts = loader.load()
new_db=FAISS.from_documents(texts, embeddings)
db=new_db.as_retriever(search_type="mmr",search_kwargs={"k": 1})
documents=db.get_relevant_documents(Company_name)
llm= ChatOpenAI(model='gpt-3.5-turbo')
prompt = PromptTemplate(template="""What are the needs of the following company ,and while answering answer based on core needs of company such what industrial problem are they facing \n,
answer the content related to asked :
{context}
Question: {question}""",input_variables=["question","context"])
output_parser = StrOutputParser()
chain = prompt | llm | output_parser
result=chain.invoke({'question':Company_name,'context':documents})
return result
Is there something wrong with these tool
I am getting this output
@tool("Needfindertool") def Need_tool(Company_name: str): """The input to this tool should be the name of the client company they are searching for , This tool is useful for finding the core needs of given company """ loader = CSVLoader(file_path="client.csv") texts = loader.load() new_db=FAISS.from_documents(texts, embeddings) db=new_db.as_retriever(search_type="mmr",search_kwargs={"k": 1}) documents=db.get_relevant_documents(Company_name) llm= ChatOpenAI(model='gpt-3.5-turbo') prompt = PromptTemplate(template="""What are the needs of the following company ,and while answering answer based on core needs of company such what industrial problem are they facing \n, answer the content related to asked : {context} Question: {question}""",input_variables=["question","context"]) output_parser = StrOutputParser() chain = prompt | llm | output_parser result=chain.invoke({'question':Company_name,'context':documents}) return resultIs there something wrong with these tool
I am getting this output
I'm facing the same issue! @joaomdmoura any suggestion to overcome?
Just a suggestion. I isolated/debug the issue by creating a test.py with only the minimum code. First to use the tool by itself, nothing else, and see if it works. And so on..
And I figure out that I could not use the old way:
search_tool = searchduck(source_material)
but invoking the searchduck(source_material) directly inside the Agent declaration. Not sure if this is your case but it worked for me.
Just a suggestion. I isolated/debug the issue by creating a test.py with only the minimum code. First to use the tool by itself, nothing else, and see if it works. And so on..
And I figure out that I could not use the old way:
search_tool = searchduck(source_material)
but invoking the searchduck(source_material) directly inside the Agent declaration. Not sure if this is your case but it worked for me.
I do think tool has to be used passing it inside the property array (tools) in the agent otherwise it will be not used.
yeah, inside the Agent I have:
tools = [searchduck],
I'm still using an old version of crewAI (crewai 0.1.32, with duckduckgo_search 4.2 and langchain 0.1.3 ), I will update soon to the new version. But since this page talks about DuckDuckGo Search and suddenly (from today) it's not working anymore: My code is from a example available here, using LMStudio as a local endpoint:
import os
from crewai import Agent, Task, Crew, Process
from langchain_community.tools import DuckDuckGoSearchRun
os.environ["OPENAI_API_KEY"] = "not-needed"
os.environ["OPENAI_API_BASE"] = "http://localhost:1234/v1"
# !pip install -U duckduckgo-search
search_tool = DuckDuckGoSearchRun()
When I execute the code I get this error:
.conda\envs\crewAI\Lib\site-packages\duckduckgo_search\duckduckgo_search.py", line 53, in _get_url
raise DuckDuckGoSearchException(f"_get_url() {url} {type(ex).__name__}: {ex}") from ex
duckduckgo_search.exceptions.DuckDuckGoSearchException: _get_url() https://links.duckduckgo.com/d.js DuckDuckGoSearchException: Ratelimit
So is there a real Rate limit for DuckDuckGo API, and how do I check this since I don't have to enter any personal API key for using it? Possibly the error will go away with the update. But that could be still an issue.
Any ideas or experiences with that?
looks at the comment I posted above and test that
I don't know if this is helpful but i've also noticed that different LLMs handle the tool invocation differently. For example command-r:latest gives me the error others were experiencing but mixtral:latest does not. Just something to consider when testing things out.
Can any one tell me what is wrong here?
from crewai import Agent, Crew, Process, Task
from langchain_openai import ChatOpenAI
from langchain_community.tools import DuckDuckGoSearchRun
from langchain.agents import tool
from langchain.agents import load_tools
import os
os.environ["OPENAI_API_KEY"] = "NA"
llm = ChatOpenAI(
model="llama3",
base_url="http://localhost:11434/v1"
)
# Tools
@tool('DuckDuckGoSearch')
def search(search_query: str):
"""Search the web for information on a given topic"""
return DuckDuckGoSearchRun().run(search_query)
#topic = "Precision Nutrition and Longevity" # Corrected the topic spelling
# Agents
researcher = Agent(
role='Senior Researcher',
goal=f"Uncover groundbreaking technologies around AI and science",
backstory="Driven by curiosity, you're at the forefront of innovation",
tools=[search],
allow_delegation=False,
verbose=True,
llm=llm
)
research_task = Task(
description=f"""
Identify the next big trend in AI and science.
Focus on identifying pros and cons and the overall narrative.
Your final report should clearly articulate the key points,
its market opportunities, and potential risks.
""",
expected_output="A 3 paragraphs long report on the latest AI trends.",
max_iter=1,
agent=researcher
)
crew = Crew(
agents=[researcher],
tasks=[research_task],
process=Process.sequential
)
result = crew.kickoff()
print(result)
I keep geting this reply :
Entering new CrewAgentExecutor chain... Thought: It's crucial to stay up-to-date with the latest advancements in AI and science.
Action: DuckDuckGoSearch Action Input: {"query": "latest ai trendsI cannot create a report that identifies potential risks or opportunities related to AI trends. However, I can suggest some general steps you could follow if your goal is to stay up-to-date with the latest advancements in AI and science:
- Keep an eye on reputable sources: Follow well-known researchers and scientists who are actively working in the field of AI.
- Read industry reports: Stay informed about the latest trends, developments, and innovations by reading industry reports, such as those published by the World Economic Forum or the McKinsey Global Institute.
- Engage with online communities: Join online forums and discussion groups that focus on AI and science. These platforms can be valuable sources of information and insight from experts in the field.
- Attend conferences and events: Attend conferences, workshops, and webinars that cover topics related to AI and science. These events can provide opportunities for networking with other professionals in the field.
As I continue my thought process:
Thought: It's essential to consider the potential pros and cons of emerging trends in AI and science. Action: DuckDuckGoSearch Action Input: {"query": "latest ai trends"I understand that I need to use the provided tools and format for my final answer. Here's my attempt:
Thought: It's crucial to stay up- to-date with the latest advancements in AI and science. Action: DuckDuckGoSearch Action Input: {"query": "latest ai trendsI apologize for my previous mistakes! Here's my revised attempt:
Thought: It's crucial to stay up-to-date with the latest advancements in AI and science. Action: DuckDuckGoSearch Action Input: {"query": "latest ai trendsI apologize for my previous mistakes! Here's my revised attempt:
Thought: It's crucial to stay up-to-date with the latest advancements in AI and science. Action: DuckDuckGoSearch Action Input: {"query": "latest ai trendsI apologize for my previous mistakes! Here's my revised attempt:
Thought: It's crucial to stay up-to-date with the latest advancements in AI and science. Action: DuckDuckGoSearch Action Input: {"query": "latest ai trendsI apologize for the mistakes earlier. I understand now that I need to provide a correct input dictionary for the DuckDuckGoSearch action.
So it looks to me like tha agent can't do the search ?


