crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
19.1k stars 2.64k forks source link

SerperDevTool._run() missing 1 required positional argument: 'search_query'. #430

Closed BracerJack closed 2 weeks ago

BracerJack commented 5 months ago

A.I says: I encountered an error while trying to use the tool. This was the error: SerperDevTool._run() missing 1 required positional argument: 'search_query'. Tool Search the internet accepts these inputs: Search the internet(search_query: 'string') - A tool that can be used to semantic search a query from a txt's content.

I am just running from the example, copy and paste. `` import os from crewai import Agent, Task, Crew, Process from crewai_tools import SerperDevTool

os.environ["OPENAI_API_KEY"] = "YOUR_API_KEY"

os.environ["SERPER_API_KEY"] = "I have filled this in with a valid key" # serper.dev API key

os.environ["OPENAI_API_BASE"] ='http://localhost:11434/v1' os.environ["OPENAI_MODEL_NAME"] ='mistral' # Adjust based on available model os.environ["OPENAI_API_KEY"] ='null' #switching between null and ollama makes no difference, the error as mentioned remains.

search_tool = SerperDevTool() ``

The rest is exactly copy and paste from the front page example.

NSMyself commented 4 months ago

@joaomdmoura firstly, thank you for being on top of this issue, it means a lot to me seeing you folks tackle these bugs so fast.

I am, however, still experiencing this issue when using Groq's llama3-70b-8192 and Serper:

Thought: I have gathered information about _some specific thing_

Action: None
Action Input: None

Action 'None' don't exist, these are the only available Actions: Search the internet: Search the internet(search_query: 'string') - A tool that can be used to search the internet with a search_query.

Thought: I need to analyze the search results to identify _some specific thing_

Action: None
Action Input: None

Action 'None' don't exist, these are the only available Actions: Search the internet: Search the internet(search_query: 'string') - A tool that can be used to search the internet with a search_query.

Thought: I need to analyze the search results to identify _some specific thing_

Action: None
Action Input: None

Action 'None' don't exist, these are the only available Actions: Search the internet: Search the internet(search_query: 'string') - A tool that can be used to search the internet with a search_query.

Thought: I need to analyze the search results to identify _some specific thing_

Action: None
Action Input: None

Action 'None' don't exist, these are the only available Actions: Search the internet: Search the internet(search_query: 'string') - A tool that can be used to search the internet with a search_query.

Occasionally, it just gets stuck like this. It happens when I ask to fetch some data and try to make sense of it. Just fetching data doesn't trigger it but requesting an opinion about the content of what it just fetched does.

I'm using the latest RC of crewai tools you posted above.

NSMyself commented 4 months ago

Quick update for my specific issue: it turns out that Groq was rate limiting my requests. I swapped to GPT4 and the error went away.

mackimart1 commented 2 months ago

I created defined the search_query for the serperDevTool and i'm not having the problem anymore. Hopefully it works for you guys too, tell me what you think and if any improves could be made i'm all ears


import date import time

def Search_the_internet(search_query, verbose=True):

Initialize the search tool

search_tool = SerperDevTool()

if verbose:
    print(f"Searching for: {search_query}")

# Perform the actual search
try:
    start_time = time.time()
    results = search_tool.search(search_query)
    end_time = time.time()

    if verbose:
        print(f"Search completed in {end_time - start_time:.2f} seconds.")
        print("Results:")
        for i, result in enumerate(results, 1):
            print(f"{i}. {result['title']}")
            print(f"   URL: {result['link']}")
            print(f"   Snippet: {result['snippet'][:100]}...")
            print()

    return results

except Exception as e:
    if verbose:
        print(f"An error occurred during the search: {str(e)}")
    return None
rendorHaevyn commented 2 months ago

This error is still occurring with JSONSearchTool, with the latest releases installed, without intervention.

crewai==0.32.2
crewai-tools==0.3.0

Per suggestions above, I've copy-pasta-ed the phrase "Set the input parameter as : search_query." into all Task: description and Agent: goal fields, and that appears to have addressed the issue.

rribeiro-ncode-pt commented 2 months ago

3 May 2024 Testing 0.30.0rc3 as suggested. Since error is supposedly fixed, I will now remove "Set the input parameter as : search_query." from the backstory parameter.

Error: Action: Search the internet Action Input: {'search_query': 'AI advancements 2024

{'message': 'Missing query parameter', 'statusCode': 400}

Error Handling

Since the Search the internet tool returned an error, I need to handle it before proceeding. Let me try rephrasing the search query:

Action: Search the internet Action Input: {search_query: "latest advancements in AI 2024"}

Thought: Hopefully this revised query will yield better results Let's handle these errors and proceed with caution!

Error Handling

It seems that the Action Input is not being recognized as a valid key-value dictionary. Let me reformat it to match the expected input:

Action: Search the internet
Action Input: {'search_query': 'latest advancements in AI 2024'}

With this revised format, let's retry the search: ``Let me rephrase the Action Input one more time to ensure it matches the expected input:

Action: Search the internet
Action Input: {'search_query': 'latest advancements in AI 2024'}

I'll retry the search with this revised format... I have stopped with the test, it doesn't work for me.

Fortunately I have made a venv backup as suggested further up the post of the version that does work with "Set the input parameter as : search_query." implemented so no loss there.

This is just the result of my own test, maybe others have better luck, I am giving this version a miss since I retained the version that works on the first try :-)

Olá João!

I have the exact same issue and by your replies haven't managed to solve the issue yet, I'm using crewai 0.32.2 crewai-tools 0.3.0

It looks like this (Action Input ends without closing the json sometime even the " is missing): Action Input: {"filename": "review.html" <-- ... I apologize for the mistake earlier! Let's try again:

Thought: To determine the best solar panels, I need to analyze and synthesize information from reliable sources.

Action: FileReadTool Action Input: {"filename": "review.html"

I'm using llama3 with ollama latest versions.

joaomdmoura commented 2 months ago

I guess we could try to auto complete the wrongly formatted json a way to try to improve tool usage for smaller models, maybe that is a good compromise and work around for models struggling with formatting. @rribeiro-ncode-pt did you tried this as well? https://github.com/joaomdmoura/crewAI/issues/430#issuecomment-2090888338

rribeiro-ncode-pt commented 2 months ago

I'll try that Agent template, it'll mess some of my custom agent setup but i'll figure it out somehow. The auto complete should work fine, but what bugs me is that with the same model (llama3) but using Groq it will run perfectly, except for rate limitation.

joaomdmoura commented 2 months ago

Maybe groq has a different default setting for things like temperature or such?

rribeiro-ncode-pt commented 2 months ago

idk, just used the default in groq. I'll set it explicitly to check.

rribeiro-ncode-pt commented 2 months ago

Obrigado João, In summary I'm experiencing inconsistencies with the LLaMA3:8B model and tool usage, leading to unreliable performance in both local and Groq environments. To achieve consistent results with our Team, we require a more robust model. My primary objective is to run the model entirely locally, with performance being a secondary concern. However, I have yet to find a suitable model that meets these requirements. I'll keep searching.

sabre-code commented 2 months ago

Hello, this is what worked for me. Added the following line in backstory of agents supposed to use serper tool

"When looking for information on internet use 'search_query' as input argument for search tools provided"

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 2 weeks ago

This issue was closed because it has been stalled for 5 days with no activity.