crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

"duckduckgo\_search is not a valid tool"

Open jbdatascience opened this issue 2 years ago • 7 comments

Often (not always !) when I use duckduckgo as a search tool in a CrewAI setup, I get this message: "duckduckgo_search is not a valid tool"

What can be the cause of this and how can I avoid getting that ?

This is a relevant piece of my code:

import os from crewai import Agent, Task, Crew, Process from langchain.tools import DuckDuckGoSearchRun search_tool = DuckDuckGoSearchRun() from langchain.llms import Ollama

Define your agents with roles and goals

researcher = Agent( role='Senior Research Analyst', goal='Uncover cutting-edge developments in Physics based on Machs principle', backstory="""You are an absolute expert at a Physics research group, especially on Machs principle and Machs Gravity, skilled in identifying trends and analyzing complex data.""", verbose=True, allow_delegation=False, tools=[search_tool], llm=local_openai_client # llm #ollama_llm )

Etc.

jbdatascience avatar Jan 24 '24 19:01 jbdatascience

The issue is that the tool in your code is called search_tool not duckduckgo_search so maybe the llm hallucinate and messed up the name of the tool so CrewAI didn't recognize it as a valid tool , one fix that may work is to do some prompt engineering in your prompts to lead the llm to use the tool with the correct name when needed

sc00rpi0n avatar Jan 26 '24 01:01 sc00rpi0n

As a work around for this issue that worked for me, you can instantiate the tool as a new Langchain Tool and specifically give it the name of "search_tool". It's a little hackish, but works. I'm guessing CrewAI is confusing the langchain tool names with the object instance name of the tool.

search = DuckDuckGoSearchRun()
search_tool = Tool(
    name="search\_tool",
    description="A search tool used to query DuckDuckGo for search results when trying to find information from the internet.",
    func=search.run
)

Then call the name of the tool you created (in this case search_tool in the task:

research_task = Task(
  description=f"""Identify the next big trend in {topic}.
  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 comprehensive 3 paragraphs long report on the latest AI trends.',
  max_inter=3,
  tools=[search_tool],
  agent=researcher
)

edsealing avatar Feb 08 '24 05:02 edsealing

same issue here, especially when I use smaller local model, that is not that flexible. It was never a problem with gpt-4. Thanks for the work around, it works.

constra avatar Feb 26 '24 15:02 constra

Hello guys, I have tried all the options above but it is still not working!

image

image

There are other alternatives I could try to make it work? As one of the guys above said, it only happens when using local models (in my case llama2)

Libraries version: crewai 0.19.0 crewai-tools 0.0.15 duckduckgo_search 5.0 langchain 0.1.11 langchain-community 0.0.25 langchain-core 0.1.29 langchain-openai 0.0.5 langchain-text-splitters 0.0.1

kaburelabs avatar Mar 06 '24 17:03 kaburelabs

try use other models than llama 2 , like openhermes is good for this stuff

sc00rpi0n avatar Mar 06 '24 18:03 sc00rpi0n

try use other models than llama 2 , like openhermes is good for this stuff

Hello mate... I downloaded and ran the openhermes and tried again but without success.

After doing the changes suggested on this topic it finally worked https://github.com/joaomdmoura/crewAI/issues/316

kaburelabs avatar Mar 06 '24 19:03 kaburelabs

To add to this, I only run into this problem when using text-generation-webui and emulating the OpenAI API.

I was running some tests with LocalAI and found that this change was not necessary at all and it worked out of the box. Therefore, it's very possible the problem is specifically with the TextGen-Webui implementation of the OpenAI API spec.

As a work around for this issue that worked for me, you can instantiate the tool as a new Langchain Tool and specifically give it the name of "search_tool". It's a little hackish, but works. I'm guessing CrewAI is confusing the langchain tool names with the object instance name of the tool.

search = DuckDuckGoSearchRun()
search_tool = Tool(
    name="search\_tool",
    description="A search tool used to query DuckDuckGo for search results when trying to find information from the internet.",
    func=search.run
)

Then call the name of the tool you created (in this case search_tool in the task:

research_task = Task(
  description=f"""Identify the next big trend in {topic}.
  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 comprehensive 3 paragraphs long report on the latest AI trends.',
  max_inter=3,
  tools=[search_tool],
  agent=researcher
)

edsealing avatar Mar 06 '24 19:03 edsealing

Solution by @edsealing worked for me. Thanks

Libraries version: crewai==0.30.11 crewai-tools==0.2.6 duckduckgo_search==6.1.7

m4ttgit avatar Jun 20 '24 10:06 m4ttgit