Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoogleSerperAPIWrapper gives error " Input should be a valid string [type=string_type, input_value={'description': 'Dr. Mihi...n field', 'type': 'str'}, input_type=dict] For further information visit https://errors.pydantic.dev/2.10/v/string_type." #2046

Closed
Ansumanbhujabal opened this issue Feb 6, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@Ansumanbhujabal
Copy link

Description

While using GoogleSerperAPIWrapper as a tool in CrewAi Multi agents system , frequently getting this error these days . Which generally makes the agent slow .


I encountered an error while trying to use the tool. This was the error: Arguments validation failed: 1 validation error for Googlesearchtool
search_query
  Input should be a valid string [type=string_type, input_value={'description': 'Dr. Mihi...n field', 'type': 'str'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/string_type.
 Tool GoogleSearchTool accepts these inputs: Tool Name: GoogleSearchTool
Tool Arguments: {'search_query': {'description': None, 'type': 'str'}}
Tool Description: Performs a search using the GoogleSearchTool.

Steps to Reproduce

Sample Serper use

search = GoogleSerperAPIWrapper()
@tool("GoogleSearchTool")
def Google_search_tool(search_query: str):
    """Performs a search using the GoogleSearchTool."""
    return search().run(search_query)
## Defining Agents

famous_personality_reviewer_agent = Agent(role=
                          "Senior Content Validator and fact checker",
                          goal="Validate the content with facts and get the most correct content", 
                          backstory=
                          """
                          You are a Senior Content Validator and fact checker  who has been assigned to validate the task 
                          for the {career_name} field if {famous_personalities_name} You will give best fact based 
                          """,
                          llm=llm,
                          tools = [Google_search_tool],
                          verbose=True)

inputs = {
        "career_name": "Automobile Engineer",
       "famous_personalities_name": "Dr. Mihir Shah \nRajendra Singh \nAnupam Mishra \nAyyappa Masagi "
               }

Error is

I encountered an error while trying to use the tool. This was the error: Arguments validation failed: 1 validation error for Googlesearchtool
search_query
  Input should be a valid string [type=string_type, input_value={'description': 'Dr. Mihi...n field', 'type': 'str'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/string_type.
 Tool GoogleSearchTool accepts these inputs: Tool Name: GoogleSearchTool
Tool Arguments: {'search_query': {'description': None, 'type': 'str'}}
Tool Description: Performs a search using the GoogleSearchTool.

Dependecies

agentneo==1.2.3
cachetools==5.5.0
certifi==2024.12.14
crewai==0.95.0
crewai-tools==0.32.0
GitPython==3.1.44
google-api-core==2.24.0
google-auth==2.37.0
google-cloud-aiplatform==1.77.0
google-cloud-bigquery==3.27.0
google-cloud-core==2.4.1
google-cloud-resource-manager==1.14.0
google-cloud-storage==2.19.0
google-crc32c==1.6.0
google-resumable-media==2.7.2
googleapis-common-protos==1.66.0
groq==0.13.1
grpc-google-iam-v1==0.14.0
langchain==0.3.17
langchain-cohere==0.3.4
langchain-community==0.3.16
langchain-core==0.3.33
langchain-exa==0.2.1
langchain-experimental==0.3.4
langchain-groq==0.2.2
langchain-openai==0.2.14
langchain-pinecone==0.2.0
langchain-text-splitters==0.3.5
pydantic==2.10.4
pydantic-settings==2.7.1
pydantic_core==2.27.2
scrapegraph_py==1.10.0
selenium==4.27.1
serpapi==0.1.5
setuptools==75.8.0

Expected behavior

This error should not be coming.

Screenshots/Code snippets

Image

Operating System

Ubuntu 20.04

Python Version

3.10

crewAI Version

0.95.0

crewAI Tools Version

0.32.0

Virtual Environment

Venv

Evidence

Image

Possible Solution

None

Additional context

None

@Ansumanbhujabal Ansumanbhujabal added the bug Something isn't working label Feb 6, 2025
@Vidit-Ostwal
Copy link
Contributor

There should be somer error with how you are passing the arguement to the tool, can you share the entire code here once?

@Ansumanbhujabal
Copy link
Author

There should be somer error with how you are passing the arguement to the tool, can you share the entire code here once?

Sure , the code simply contains a bunch of more agents like this and their specific tasks.

famous_personality_reviewer_task = Task(description=
                        """
                          Your task is to validate and fact-check .             
                          for the {career_name} field if {famous_personalities_name} are correct famous personality name or not.
                          on the ground of 
                          1. The persons have workied in the {career_name} field directly in the real work.
                          2. THey must predominantly known for this specific {career_name} field , not nay other.
                          3. They have contributed significantly to that field and people consider them as great for their Knowledge,Innovation, Dedication to that specific {career_name} field .
                          4. They are not involved in Criminal offences.
                          5. They are not  passive contributors like investors,industrialists, activists. 
                        """,
                        expected_output=""" Give label "RIGHT" if all names satisfies all grounds , "WRONG" if even one ground is not satisfied """,
                        agent=famous_personality_reviewer_agent)
crew = Crew(agents=[ famous_personality_reviewer_agent], 
            tasks=[famous_personality_reviewer_task], 
            verbose=True)

@Vidit-Ostwal
Copy link
Contributor

@Ansumanbhujabal , I think the problem is because of the \n you are trying to pass

I think even if you remove that and replace with a ',', I think this should work,
Otherway around is you can use """Dr. Mihir Shah \nRajendra Singh \nAnupam Mishra \nAyyappa Masagi""", with triple "" instead of single "",
Try this out once.

@Ansumanbhujabal
Copy link
Author

After bumping my head for few days , I found that it was more of a LLM issue for not correctly choosing the format required for tool call . Serper expects a string input , although my input was string , but the llm was passing it as dictionary in tool calling.
refer -https://community.crewai.com/t/tool-calling-not-adhering-to-schema/679/9

I fixed it by explicitly prompting this fact to the agent.

top_companies_reviewer_agent = Agent(role=
                          "Senior Content Validator and fact checker",
                          goal="Validate the content with facts and get the most correct content", 
                          backstory=
                          """
                          You are a Senior Content Validator and fact checker  who has been assigned to validate the task 
                          for the {career_name} field if {top_companies}   are correct companies or not.
                          The tools you have access accept strings as input parameter only.
                          """,
                          llm=llm,
                          tools = [duck_search,Google_search_tool],
                          verbose=True)

Closing this issue since it is not CrewAi specific , feel free to reopen if further problems are faced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants