forked from Archives/langchain
Replaced SQLDatabaseChain
deprecated direct initialisation with from_llm
method (#4778)
# Removed usage of deprecated methods Replaced `SQLDatabaseChain` deprecated direct initialisation with `from_llm` method ## Who can review? @hwchase17 @agola11 --------- Co-authored-by: imeckr <chandanroutray2012@gmail.com> Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
This commit is contained in:
parent
11341fcecb
commit
e8d46bdd9b
@ -42,7 +42,7 @@
|
|||||||
"search = SerpAPIWrapper()\n",
|
"search = SerpAPIWrapper()\n",
|
||||||
"llm_math_chain = LLMMathChain(llm=llm, verbose=True)\n",
|
"llm_math_chain = LLMMathChain(llm=llm, verbose=True)\n",
|
||||||
"db = SQLDatabase.from_uri(\"sqlite:///../../../../../notebooks/Chinook.db\")\n",
|
"db = SQLDatabase.from_uri(\"sqlite:///../../../../../notebooks/Chinook.db\")\n",
|
||||||
"db_chain = SQLDatabaseChain(llm=llm, database=db, verbose=True)\n",
|
"db_chain = SQLDatabaseChain.from_llm(llm, db, verbose=True)\n",
|
||||||
"tools = [\n",
|
"tools = [\n",
|
||||||
" Tool(\n",
|
" Tool(\n",
|
||||||
" name = \"Search\",\n",
|
" name = \"Search\",\n",
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
"search = SerpAPIWrapper()\n",
|
"search = SerpAPIWrapper()\n",
|
||||||
"llm_math_chain = LLMMathChain(llm=llm1, verbose=True)\n",
|
"llm_math_chain = LLMMathChain(llm=llm1, verbose=True)\n",
|
||||||
"db = SQLDatabase.from_uri(\"sqlite:///../../../../../notebooks/Chinook.db\")\n",
|
"db = SQLDatabase.from_uri(\"sqlite:///../../../../../notebooks/Chinook.db\")\n",
|
||||||
"db_chain = SQLDatabaseChain(llm=llm1, database=db, verbose=True)\n",
|
"db_chain = SQLDatabaseChain.from_llm(llm1, db, verbose=True)\n",
|
||||||
"tools = [\n",
|
"tools = [\n",
|
||||||
" Tool(\n",
|
" Tool(\n",
|
||||||
" name = \"Search\",\n",
|
" name = \"Search\",\n",
|
||||||
|
@ -213,7 +213,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"chain = SQLDatabaseChain(llm=llm, database=db, input_key=\"question\")"
|
"chain = SQLDatabaseChain.from_llm(llm, db, input_key=\"question\")"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -415,7 +415,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.9.1"
|
"version": "3.11.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
@ -307,7 +307,9 @@ def _load_sql_database_chain(config: dict, **kwargs: Any) -> SQLDatabaseChain:
|
|||||||
if "prompt" in config:
|
if "prompt" in config:
|
||||||
prompt_config = config.pop("prompt")
|
prompt_config = config.pop("prompt")
|
||||||
prompt = load_prompt_from_config(prompt_config)
|
prompt = load_prompt_from_config(prompt_config)
|
||||||
return SQLDatabaseChain(database=database, llm=llm, prompt=prompt, **config)
|
else:
|
||||||
|
prompt = None
|
||||||
|
return SQLDatabaseChain.from_llm(llm, database, prompt=prompt, **config)
|
||||||
|
|
||||||
|
|
||||||
def _load_vector_db_qa_with_sources_chain(
|
def _load_vector_db_qa_with_sources_chain(
|
||||||
|
@ -223,8 +223,8 @@ class SQLDatabaseSequentialChain(Chain):
|
|||||||
**kwargs: Any,
|
**kwargs: Any,
|
||||||
) -> SQLDatabaseSequentialChain:
|
) -> SQLDatabaseSequentialChain:
|
||||||
"""Load the necessary chains."""
|
"""Load the necessary chains."""
|
||||||
sql_chain = SQLDatabaseChain(
|
sql_chain = SQLDatabaseChain.from_llm(
|
||||||
llm=llm, database=database, prompt=query_prompt, **kwargs
|
llm, database, prompt=query_prompt, **kwargs
|
||||||
)
|
)
|
||||||
decider_chain = LLMChain(
|
decider_chain = LLMChain(
|
||||||
llm=llm, prompt=decider_prompt, output_key="table_names"
|
llm=llm, prompt=decider_prompt, output_key="table_names"
|
||||||
|
Loading…
Reference in New Issue
Block a user