Serper API tool from crewai tools throwing validation error

Following is my code for Automated Event Planning from the course-

Following is how i set up my llm and the code-

Blockquote

groq_llm = LLM(
model=“groq/llama3-8b-8192”,
temperature=0.3,
max_tokens=4096,
api_key=groq_api_key,
)

from crewai_tools import ScrapeWebsiteTool, SerperDevTool
search_tool = SerperDevTool()
scrape_tool = ScrapeWebsiteTool()
venue_coordinator = Agent(
role=“Venue Coordinator”,
goal=“required text”,
verbose=True,
backstory=(
“required text”
),
llm=groq_llm,
tools=[search_tool, scrape_tool],
)

Blockquote

Similarly i create other agents and tasks by following the code. But in crew.kickoff i get the following error-

I encountered an error while trying to use the tool. This was the error: 1 validation error for SerperDevToolSchema
search_query
Input should be a valid string [type=string_type, input_value={‘description’: ‘tech inn…ancisco’, ‘type’: ‘str’}, input_type=dict]
For further information visit Redirecting....
Tool Search the internet accepts these inputs: Tool Name: Search the internet
Tool Arguments: {‘search_query’: {‘description’: ‘Mandatory search query you want to use to search the internet’, ‘type’: ‘str’}}
Tool Description: A tool that can be used to search the internet with a search_query.

Please give suggestions for resolving the same. Thanks in advance.
Let me know if further information is required.

@Srishti_Nagu Which LLM is used in the course? Llama 3 8B? Try to switch to a more capable LLM.

I got good results using gemini-1.5-flash.
You can setup an environment variable GEMINI_API_KEY with the key generated from https://aistudio.google.com/app/apikey , use this env variable when creating instance of LLM() you should be good to go.

Example of how i used it.

1 Like

Hi @rokbenko , In the course- gpt-3.5-turbo is used. I tried the following models from Groq- mixtral-8x7b-32768, llama-3.1-70b-versatile, llama3-70b-8192.
But getting the same error.

Hi @vkrishna, I tried Gemini models and got the results. But it is still throwing the error while running.

Error- I encountered an error while trying to use the tool. This was the error: Invalid leading whitespace, reserved character(s), or return character(s) in header value: ‘dd20d9f64365420d87b5059f1d846f3c3a28334c\r\n’.
Tool Search the internet accepts these inputs: Tool Name: Search the internet
Tool Arguments: {‘search_query’: {‘description’: ‘Mandatory search query you want to use to search the internet’, ‘type’: ‘str’}}
Tool Description: A tool that can be used to search the internet with a search_query.

I want to confirm if there is any issue in my code ?

Thanks

Can you share your task config, please and also your agents

Hi @matt, sure.
Following is my code for LLM, agents and tasks-

from crewai import LLM
gem_llm = LLM(model=“gemini/gemini-1.5-flash”, api_key=gemini_api_key)

Blockquote
venue_coordinator = Agent(
role=“Venue Coordinator”,
goal="Identify and book an appropriate venue "
“based on event requirements”,
verbose=True,
backstory=(
“With a keen sense of space…”
),
llm=gem_llm, #groq_llm,
tools=[search_tool, scrape_tool],
)
logistics_manager = Agent(
role=‘Logistics Manager’,
goal=(
"Manage all logistics for the event "
“including catering and equipment”
),
verbose=True,
backstory=(
“Organized and detail-oriented…”
),
llm=gem_llm, #groq_llm,
tools=[search_tool, scrape_tool],
)

marketing_communications_agent = Agent(
role=“Marketing and Communications Agent”,
goal="Effectively market the event and "
“communicate with participants”,
verbose=True,
backstory=(
“Creative and communicative…”
),
llm=gem_llm, #groq_llm,
tools=[search_tool, scrape_tool]
)
venue_task = Task(
description="Find a venue in {event_city} "
“that meets criteria for {event_topic}.”,
expected_output=“All the details of a specifically chosen”
“venue you found to accommodate the event.”,
human_input=True,
output_json=VenueDetails,
output_file=“venue_details.json”,
agent=venue_coordinator
)
logistics_task = Task(
description="Coordinate catering and "
"equipment for an event "
"with {expected_participants} participants "
“on {tentative_date}.”,
expected_output="Confirmation of all logistics arrangements "
“including catering and equipment setup.”,
human_input=True,
async_execution=True,
agent=logistics_manager
)
marketing_task = Task(
description="Promote the {event_topic} "
“aiming to engage at least”
“{expected_participants} potential attendees.”,
expected_output="Report on marketing activities "
“and attendee engagement formatted as markdown.”,
# async_execution=True,
output_file=“marketing_report.md”, # Outputs the report as a text file
agent=marketing_communications_agent
)
event_management_crew = Crew(
agents=[venue_coordinator,
logistics_manager,
marketing_communications_agent],

tasks=[venue_task,
       logistics_task,
       marketing_task],

verbose=True

)

Blockquote

Let me know if further information is required.