mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-22 12:20:14 +00:00
2.4 KiB
2.4 KiB
In [4]:
from langchain.chains import create_sql_query_chain
from langchain.chat_models import ChatOpenAI
from langchain.utilities import SQLDatabaseIn [7]:
db = SQLDatabase.from_uri("sqlite:///../../../../notebooks/Chinook.db")In [8]:
chain = create_sql_query_chain(ChatOpenAI(temperature=0), db)In [12]:
response = chain.invoke({"question":"How many employees are there"})In [14]:
print(response)SELECT COUNT(*) FROM Employee
In [15]:
db.run(response)Out [15]:
'[(8,)]'
In [ ]: