Spaces:
Running
Running
Commit
·
b1222b7
1
Parent(s):
89b6dbf
Add Population Data Tables
Browse files- agent.py +1 -1
- app.py +6 -0
- create_table.sql +13 -0
agent.py
CHANGED
@@ -62,7 +62,7 @@ def create_assistant_tools(cfg):
|
|
62 |
|
63 |
db_tools = tools_factory.database_tools(
|
64 |
tool_name_prefix = "cfpb",
|
65 |
-
content_description = 'Customer complaints about five banks (Bank of America, Wells Fargo, Capital One, Chase, and CITI Bank)',
|
66 |
sql_database = SQLDatabase(create_engine('sqlite:///cfpb_database.db')),
|
67 |
)
|
68 |
|
|
|
62 |
|
63 |
db_tools = tools_factory.database_tools(
|
64 |
tool_name_prefix = "cfpb",
|
65 |
+
content_description = 'Customer complaints about five banks (Bank of America, Wells Fargo, Capital One, Chase, and CITI Bank) and geographic information (counties and zip codes)',
|
66 |
sql_database = SQLDatabase(create_engine('sqlite:///cfpb_database.db')),
|
67 |
)
|
68 |
|
app.py
CHANGED
@@ -48,6 +48,12 @@ def setup_db():
|
|
48 |
df = load_dataset("vectara/cfpb-complaints", data_files="cfpb_complaints.csv", token=hf_token)['train'].to_pandas()
|
49 |
df.to_sql('cfpb_complaints', conn, if_exists='replace', index=False)
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
# Commit changes and close connection
|
52 |
conn.commit()
|
53 |
conn.close()
|
|
|
48 |
df = load_dataset("vectara/cfpb-complaints", data_files="cfpb_complaints.csv", token=hf_token)['train'].to_pandas()
|
49 |
df.to_sql('cfpb_complaints', conn, if_exists='replace', index=False)
|
50 |
|
51 |
+
df = load_dataset("vectara/cfpb-complaints", data_files="cfpb_county_populations.csv", token=hf_token)['train'].to_pandas()
|
52 |
+
df.to_sql('cfpb_county_populations', conn, if_exists='replace', index=False)
|
53 |
+
|
54 |
+
df = load_dataset("vectara/cfpb-complaints", data_files="cfpb_zip_to_county.csv", token=hf_token)['train'].to_pandas()
|
55 |
+
df.to_sql('cfpb_zip_to_county', conn, if_exists='replace', index=False)
|
56 |
+
|
57 |
# Commit changes and close connection
|
58 |
conn.commit()
|
59 |
conn.close()
|
create_table.sql
CHANGED
@@ -12,4 +12,17 @@ CREATE TABLE cfpb_complaints (
|
|
12 |
report_method VARCHAR(12),
|
13 |
complaint_status VARCHAR(31),
|
14 |
timely_response INTEGER
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
);
|
|
|
12 |
report_method VARCHAR(12),
|
13 |
complaint_status VARCHAR(31),
|
14 |
timely_response INTEGER
|
15 |
+
);
|
16 |
+
|
17 |
+
CREATE TABLE county_populations (
|
18 |
+
state VARCHAR(2),
|
19 |
+
county VARCHAR(39),
|
20 |
+
year INTEGER,
|
21 |
+
population INTEGER
|
22 |
+
);
|
23 |
+
|
24 |
+
CREATE TABLE zip_codes_and_counties (
|
25 |
+
state VARCHAR(2),
|
26 |
+
county VARCHAR(28),
|
27 |
+
zip_code INTEGER
|
28 |
);
|