File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
docs/modules/chains/examples Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 266
266
"metadata" : {},
267
267
"outputs" : [],
268
268
"source" : [
269
- " from langchain.chains.sql_database.base import SQLDatabaseSequentialChain"
269
+ " from langchain.chains import SQLDatabaseSequentialChain"
270
270
]
271
271
},
272
272
{
293
293
" \n " ,
294
294
" \u001b [1m> Entering new SQLDatabaseSequentialChain chain...\u001b [0m\n " ,
295
295
" Table names to use:\n " ,
296
- " \u001b [33;1m\u001b [1;3m['Employee', 'Customer']\u001b [0m\n " ,
296
+ " \u001b [33;1m\u001b [1;3m['Customer', 'Employee']\u001b [0m\n " ,
297
+ " \n " ,
298
+ " \u001b [1m> Entering new SQLDatabaseChain chain...\u001b [0m\n " ,
299
+ " How many employees are also customers? \n " ,
300
+ " SQLQuery:\u001b [32;1m\u001b [1;3m SELECT COUNT(*) FROM Customer c INNER JOIN Employee e ON c.SupportRepId = e.EmployeeId;\u001b [0m\n " ,
301
+ " SQLResult: \u001b [33;1m\u001b [1;3m[(59,)]\u001b [0m\n " ,
302
+ " Answer:\u001b [32;1m\u001b [1;3m There are 59 employees who are also customers.\u001b [0m\n " ,
303
+ " \u001b [1m> Finished chain.\u001b [0m\n " ,
304
+ " \n " ,
297
305
" \u001b [1m> Finished chain.\u001b [0m\n "
298
306
]
299
307
},
300
308
{
301
309
"data" : {
302
310
"text/plain" : [
303
- " ' 0 employees are also customers.'"
311
+ " ' There are 59 employees who are also customers.'"
304
312
]
305
313
},
306
314
"execution_count" : 5 ,
Original file line number Diff line number Diff line change 12
12
from langchain .chains .qa_with_sources .base import QAWithSourcesChain
13
13
from langchain .chains .qa_with_sources .vector_db import VectorDBQAWithSourcesChain
14
14
from langchain .chains .sequential import SequentialChain , SimpleSequentialChain
15
- from langchain .chains .sql_database .base import SQLDatabaseChain
15
+ from langchain .chains .sql_database .base import (
16
+ SQLDatabaseChain ,
17
+ SQLDatabaseSequentialChain ,
18
+ )
16
19
from langchain .chains .transform import TransformChain
17
20
from langchain .chains .vector_db_qa .base import VectorDBQA
18
21
35
38
"TransformChain" ,
36
39
"MapReduceChain" ,
37
40
"OpenAIModerationChain" ,
41
+ "SQLDatabaseSequentialChain" ,
38
42
]
Original file line number Diff line number Diff line change @@ -109,7 +109,9 @@ def from_llm(
109
109
** kwargs : Any ,
110
110
) -> SQLDatabaseSequentialChain :
111
111
"""Load the necessary chains."""
112
- sql_chain = SQLDatabaseChain (llm = llm , database = database , prompt = query_prompt )
112
+ sql_chain = SQLDatabaseChain (
113
+ llm = llm , database = database , prompt = query_prompt , ** kwargs
114
+ )
113
115
decider_chain = LLMChain (
114
116
llm = llm , prompt = decider_prompt , output_key = "table_names"
115
117
)
You can’t perform that action at this time.
0 commit comments