Spaces:
Running
Running
Matthias Mohr
commited on
Commit
•
54447d6
1
Parent(s):
60b99bb
Add data sources
Browse files- fiboa/app.py +12 -4
- fiboa/data.py +22 -0
- requirements.txt +1 -1
fiboa/app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import ibis
|
|
|
2 |
import streamlit as st
|
3 |
|
4 |
from langchain.chains import create_sql_query_chain
|
@@ -7,11 +8,18 @@ from langchain_core.prompts.prompt import PromptTemplate
|
|
7 |
from langchain_openai import ChatOpenAI
|
8 |
|
9 |
from query import execute_prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
geoparquet = "https://data.source.coop/fiboa/be-vlg/be_vlg.parquet"
|
12 |
-
con = ibis.
|
13 |
-
|
14 |
-
|
|
|
15 |
|
16 |
st.set_page_config(
|
17 |
page_title="fiboaGPT",
|
@@ -50,7 +58,7 @@ llm = ChatOpenAI(model="gpt-4o-mini", temperature=0, api_key=st.secrets["OPENAI_
|
|
50 |
|
51 |
# Create the SQL query chain with the custom prompt
|
52 |
db = SQLDatabase.from_uri("duckdb:///duck.db", view_support=True)
|
53 |
-
chain = create_sql_query_chain(llm, db, prompt=new_prompt, k=
|
54 |
|
55 |
'''
|
56 |
Ask me about fiboa data! Request "a map" to get map output, or table for tabular output, e.g.
|
|
|
1 |
import ibis
|
2 |
+
import os
|
3 |
import streamlit as st
|
4 |
|
5 |
from langchain.chains import create_sql_query_chain
|
|
|
8 |
from langchain_openai import ChatOpenAI
|
9 |
|
10 |
from query import execute_prompt
|
11 |
+
# from data import DATA
|
12 |
+
|
13 |
+
if os.path.exists("duck.db"):
|
14 |
+
os.remove("duck.db")
|
15 |
+
if os.path.exists("duck.db.wal"):
|
16 |
+
os.remove("duck.db.wal")
|
17 |
|
18 |
geoparquet = "https://data.source.coop/fiboa/be-vlg/be_vlg.parquet"
|
19 |
+
con = ibis.connect("duckdb://duck.db", extensions = ["spatial"])
|
20 |
+
con.read_parquet(geoparquet, "crops").cast({"geometry": "geometry"})
|
21 |
+
# for code, url in DATA.items():
|
22 |
+
# tbl = con.read_parquet(url, code).cast({"geometry": "geometry"})
|
23 |
|
24 |
st.set_page_config(
|
25 |
page_title="fiboaGPT",
|
|
|
58 |
|
59 |
# Create the SQL query chain with the custom prompt
|
60 |
db = SQLDatabase.from_uri("duckdb:///duck.db", view_support=True)
|
61 |
+
chain = create_sql_query_chain(llm, db, prompt=new_prompt, k=100)
|
62 |
|
63 |
'''
|
64 |
Ask me about fiboa data! Request "a map" to get map output, or table for tabular output, e.g.
|
fiboa/data.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
DATA = {
|
2 |
+
"at":"https://data.source.coop/fiboa/austria/inspire_referenzen_2021.parquet",
|
3 |
+
"de_bb":"https://data.source.coop/fiboa/de-bb/dfbk.parquet",
|
4 |
+
"de_nds":"https://data.source.coop/fiboa/de-nds/FB_NDS.parquet",
|
5 |
+
"de_nrw":"https://data.source.coop/fiboa/de-nrw/LFK-AKTI.parquet",
|
6 |
+
"de_th":"https://data.source.coop/fiboa/de-th/de-th.parquet",
|
7 |
+
"de_sh":"https://data.source.coop/fiboa/de-sh/Feldbloecke_2024.parquet",
|
8 |
+
"ec_si":"https://data.source.coop/fiboa/slovenia-ec/data/slovenia_eurocrops_2021.parquet",
|
9 |
+
"ec_lv":"https://data.source.coop/fiboa/ec-lv/ec_lv.parquet",
|
10 |
+
"fi":"https://data.source.coop/fiboa/finland/finland.parquet",
|
11 |
+
"ec_fr":"https://data.source.coop/fiboa/france-ec/france_eurocrops_2018.parquet",
|
12 |
+
"nl":"https://data.source.coop/fiboa/nl-ref/nl_ref.parquet",
|
13 |
+
"nl_crop":"https://data.source.coop/fiboa/nl-crop/nl_crop.parquet",
|
14 |
+
"ai4sf":"https://data.source.coop/fiboa/ai4sf/ai4sf.parquet",
|
15 |
+
"pt":"https://data.source.coop/fiboa/portugal/Continente.parquet",
|
16 |
+
"be_vlg":"https://data.source.coop/fiboa/be-vlg/be_vlg.parquet",
|
17 |
+
"br-ba-lem":"https://data.source.coop/fiboa/br-ba-lem/br-ba-lem.parquet",
|
18 |
+
"dk":"https://data.source.coop/fiboa/denmark//denmark.parquet",
|
19 |
+
"de_sax":"https://data.source.coop/fiboa/de-sax/de-sax.parquet",
|
20 |
+
"de_mv":"https://data.source.coop/fiboa/de-mv/de-mv.parquet",
|
21 |
+
"de_sl":"https://data.source.coop/fiboa/de-sl/de-sl.parquet"
|
22 |
+
}
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
duckdb==1.
|
2 |
pandas==2.2.2
|
3 |
git+https://github.com/eodaGmbH/py-maplibregl
|
4 |
leafmap[maplibre]
|
|
|
1 |
+
duckdb==1.0.0
|
2 |
pandas==2.2.2
|
3 |
git+https://github.com/eodaGmbH/py-maplibregl
|
4 |
leafmap[maplibre]
|