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

[BUG] - nl2sql tool is failing. #1855

Open
swateek opened this issue Jan 5, 2025 · 4 comments
Open

[BUG] - nl2sql tool is failing. #1855

swateek opened this issue Jan 5, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@swateek
Copy link

swateek commented Jan 5, 2025

Description

I am trying to connect to a Singlestore database with CrewAI's NL2SQL tool and I see this error

I encountered an error while trying to use the tool. This was the error: Arguments validation failed: 1 validation error for NL2SQLToolInput
sql_query
  Field required [type=missing, input_value={'query': 'SELECT DISTINC...store_name FROM stores'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/missing.
 Tool NL2SQLTool accepts these inputs: Converts natural language to SQL queries and executes them..

My code is pretty simple and straight forward, I used basic SQLAlchemy executor to verify the DB connection as well.

Steps to Reproduce

Use my code above.

Expected behavior

The Nl2sql tool must work properly when used as per the example.

Screenshots/Code snippets

from crewai import Agent, Crew, Task
from crewai_tools import NL2SQLTool

DATABASE_URI = f"mysql+pymysql://{db_cfgs["db_username"]}:{encoded_password}@{db_cfgs["db_host"]}:3306/{db_cfgs["db_name"]}"

# Define file paths for YAML configurations
files = {
    'agents': 'config/agents.yaml',
    'tasks': 'config/tasks.yaml'
}

# Load configurations from YAML files
configs = {}
for config_type, file_path in files.items():
    with open(file_path, 'r') as file:
        configs[config_type] = yaml.safe_load(file)

# Assign loaded configurations to specific variables
agents_config = configs['agents']
tasks_config = configs['tasks']

# create Agent
agent_text_to_sql = Agent(
  config=agents_config['agent_text_to_sql'],
  allow_delegation=False,
  tools=[nl2sql]
)

# create Task
task_extract_data = Task(
  config=tasks_config['task_extract_data'],
  agent=agent_text_to_sql
)

# Creating Crew
crew = Crew(
  agents=[
    agent_text_to_sql
  ],
  tasks=[
    task_extract_data
  ],
  verbose=True
)


# The given Python dictionary
inputs = {
    "sql_query": "find all distinct stores"
}

# Run the crew
result = crew.kickoff(
  inputs=inputs
)```

### Operating System

MacOS

### Python Version

3.12

### crewAI Version

0.95.0

### crewAI Tools Version

0.25.8

### Virtual Environment

Venv
@swateek swateek added the bug Something isn't working label Jan 5, 2025
@swateek
Copy link
Author

swateek commented Jan 7, 2025

any help on this?

@Neerajkumar12
Copy link

i am also facing the same issue when i try to implement NL2Sql_tool:
image

@swateek
Copy link
Author

swateek commented Jan 9, 2025

@Neerajkumar12 please add a +1 to the bug above to come up on the issue board for them.

@Hamiedamr
Copy link

image
same issue

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

3 participants