langchain icon indicating copy to clipboard operation
langchain copied to clipboard

use_query_checker in SQLDatabaseChain not working

Open sergeyvi4ev opened this issue 2 years ago • 2 comments

System Info


ValidationError Traceback (most recent call last) in <cell line: 2>() 1 # sql chain ----> 2 db_chain = SQLDatabaseChain.from_llm(llm, db, 3 return_intermediate_steps=False, # returns query and steps 4 verbose=True, use_query_checker=True, # self-correcting small mistakes 5 top_k=3 # limit the number of rows returned

1 frames /usr/local/lib/python3.10/dist-packages/pydantic/main.cpython-310-x86_64-linux-gnu.so in pydantic.main.BaseModel.init()

ValidationError: 1 validation error for SQLDatabaseChain use_query_checker extra fields not permitted (type=value_error.extra)

Who can help?

No response

Information

  • [X] The official example notebooks/scripts
  • [ ] My own modified scripts

Related Components

  • [ ] LLMs/Chat Models
  • [ ] Embedding Models
  • [ ] Prompts / Prompt Templates / Prompt Selectors
  • [ ] Output Parsers
  • [ ] Document Loaders
  • [ ] Vector Stores / Retrievers
  • [ ] Memory
  • [ ] Agents / Agent Executors
  • [ ] Tools / Toolkits
  • [X] Chains
  • [ ] Callbacks/Tracing
  • [ ] Async

Reproduction

from future import annotations

import warnings from typing import Any, Dict, List, Optional

from pydantic import Extra, Field, root_validator

from langchain.base_language import BaseLanguageModel from langchain.callbacks.manager import CallbackManagerForChainRun from langchain.chains.base import Chain from langchain.chains.llm import LLMChain from langchain.chains.sql_database.prompt import DECIDER_PROMPT, PROMPT, SQL_PROMPTS from langchain.prompts.base import BasePromptTemplate from langchain.prompts.prompt import PromptTemplate from langchain.sql_database import SQLDatabase from langchain.tools.sql_database.prompt import QUERY_CHECKER

initialize database

llm = OpenAI(temperature=0) db = SQLDatabase.from_uri("sqlite:////content/drive/My Drive/09PHD/sql-murder-mystery.db", sample_rows_in_table_info=1, # examples of rows from each table, consumes tokens # custom_table_info=custom_table_info # we can define custom table info which will override the default sample_rows_in_table_info parameter )

sql chain

db_chain = SQLDatabaseChain.from_llm(llm, db, return_intermediate_steps=False, # returns query and steps verbose=True, # use_query_checker=True, # self-correcting small mistakes NOT WORKING top_k=3 # limit the number of rows returned )

Expected behavior

The use_query_checker=True parameter in SQLDatabaseChain spits out an error.

sergeyvi4ev avatar May 13 '23 12:05 sergeyvi4ev

I'm experiencing the same issue as well

Tajcore avatar May 13 '23 18:05 Tajcore

Upgrade the langchain version ;)

vgmartinez avatar May 14 '23 16:05 vgmartinez

I did, but unforturnately the issue remains.

sergeyvi4ev avatar May 14 '23 19:05 sergeyvi4ev

Hi, @sergeyvi4ev! I'm Dosu, and I'm here to help the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

Based on the information provided, it seems that you and other users have encountered an issue with the use_query_checker parameter in SQLDatabaseChain. Despite upgrading to the latest version of LangChain, the issue remains unresolved.

If this issue is still relevant to the latest version of the LangChain repository, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself. If we don't hear back from you within 7 days, the issue will be automatically closed.

Thank you for your understanding and for your contribution to the LangChain community!

dosubot[bot] avatar Sep 12 '23 16:09 dosubot[bot]