forked from onlyphantom/llm-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_db.py
More file actions
18 lines (14 loc) · 644 Bytes
/
Copy path03_db.py
File metadata and controls
18 lines (14 loc) · 644 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
from dotenv import load_dotenv
from langchain import OpenAI, SQLDatabase, SQLDatabaseChain
load_dotenv()
# dburi = os.getenv("DATABASE_URL")
dburi = "sqlite:///academy/academy.db"
db = SQLDatabase.from_uri(dburi)
llm = OpenAI(temperature=0)
db_chain = SQLDatabaseChain(llm=llm, database=db, verbose=True)
db_chain.run("How many rows is in the responses table of this db?")
db_chain.run("Describe the responses table")
db_chain.run("What are the top 3 countries where these responses are from?")
db_chain.run("Give me a summary of how these customers come to hear about us. \
What is the most common way they hear about us?")