crewAI: [BUG] The JsonSearchTool always fails

Description

Whenever I try to use the JsonSearchTool I get the following error:

I encountered an error while trying to use the tool. This was the error: Arguments validation failed: 1 validation error for FixedJSONSearchToolSchema search_query Input should be a valid string [type=string_type, input_value={'description': 'Create a...cuments', 'type': 'str'}, input_type=dict]

This is what my setup looks like:

JSONSearchTool(
    json_path='<path/to/json>',
    config={
        "llm": {
            "provider": "azure_openai", 
            "config": {
                "model": "<deployment-name",
                "base_url": "<base-url>",
                "api_key": "<api-key>",
                "temperature":0.0,
            },
        },
        "embedding_model":{
            "provider": "ollama",
            "config": {
                "model": "nomic-embed-text"
            }
        }
    }
)

Steps to Reproduce

  1. Create an Agent with a JsonSearchTool

Expected behavior

The Agent should go look up in the Json file

Screenshots/Code snippets

Image

Operating System

macOS Catalina

Python Version

3.11

crewAI Version

0.102.0

crewAI Tools Version

not sure

Virtual Environment

Venv

Evidence

Image

Possible Solution

None.

Additional context

I read the tool needs a “search_query” field, but I don’t understand how to pass it, or how to make the agent consistently pass it.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

How can i see the prompt? utilizing verbose doesn’t give me that much info

There is no way for this to see the final_prompt which goes to llm, I just printed the prompt just before the llm call.

https://github.com/crewAIInc/crewAI/blob/efe27bd570d91f00af59f1d605d87e7b82c2bc88/src/crewai/agents/crew_agent_executor.py#L98-L105

Here I just added a print statement to print the list of messages which are going to llm

Yeah I totally understand the concern, it will only continue to add up different use cases.

Thank you for your example. The first try my agent runs it continues to fail, but it understands it and does a good request the next time.

I’ll try to modify the agent’s goal and backstory to see if I get better results.

Thank you both for your input. I’ll close this.