Spaces:
Sleeping
Sleeping
Matthias Mohr
commited on
Commit
·
3936ffe
1
Parent(s):
850e622
Improvements
Browse files- fiboa/app.py +5 -2
- fiboa/query.py +5 -1
fiboa/app.py
CHANGED
|
@@ -48,15 +48,17 @@ Pay close attention to use only the column names that you can see in the schema
|
|
| 48 |
not query for columns that do not exist. Also, pay attention to which column is in which table.
|
| 49 |
|
| 50 |
Tables include {table_info}. The data comes comes always from the table called "crops".
|
| 51 |
-
|
| 52 |
|
| 53 |
The column "area" is in the unit hectares, you may need to convert it to other units, e.g. square meters.
|
| 54 |
The column "perimeter" is in the unit meters, you may need to convert it to other units, e.g. kilometers.
|
| 55 |
-
The column "collection" contains the country codes for the Baltic states:
|
|
|
|
| 56 |
|
| 57 |
Question: {input}
|
| 58 |
'''
|
| 59 |
)
|
|
|
|
| 60 |
|
| 61 |
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0, api_key=st.secrets["OPENAI_API_KEY"])
|
| 62 |
|
|
@@ -69,6 +71,7 @@ Ask me about fiboa data (here: all baltic states)!
|
|
| 69 |
Request "a map" to get map output, or table for tabular output, e.g.
|
| 70 |
|
| 71 |
- Show a map with the 10 largest fields
|
|
|
|
| 72 |
- Show a table of the total area by crop type
|
| 73 |
- Compute the total area of all fields in km² and compute the percentage the total area of the baltic states (175015 km²)
|
| 74 |
|
|
|
|
| 48 |
not query for columns that do not exist. Also, pay attention to which column is in which table.
|
| 49 |
|
| 50 |
Tables include {table_info}. The data comes comes always from the table called "crops".
|
| 51 |
+
Never use the "testing" table. Pay close attention to this table schema.
|
| 52 |
|
| 53 |
The column "area" is in the unit hectares, you may need to convert it to other units, e.g. square meters.
|
| 54 |
The column "perimeter" is in the unit meters, you may need to convert it to other units, e.g. kilometers.
|
| 55 |
+
The column "collection" contains the country codes for the Baltic states:
|
| 56 |
+
"ec_lt" for Latvia, "ec_lv" for Lithuania, "ec_es" for Estonia.
|
| 57 |
|
| 58 |
Question: {input}
|
| 59 |
'''
|
| 60 |
)
|
| 61 |
+
# todo: if data get's updated, change "ec_es" to "ec_ee"
|
| 62 |
|
| 63 |
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0, api_key=st.secrets["OPENAI_API_KEY"])
|
| 64 |
|
|
|
|
| 71 |
Request "a map" to get map output, or table for tabular output, e.g.
|
| 72 |
|
| 73 |
- Show a map with the 10 largest fields
|
| 74 |
+
- Show a map with the largest field in Estonia
|
| 75 |
- Show a table of the total area by crop type
|
| 76 |
- Compute the total area of all fields in km² and compute the percentage the total area of the baltic states (175015 km²)
|
| 77 |
|
fiboa/query.py
CHANGED
|
@@ -11,6 +11,10 @@ def execute_prompt(con, chain, prompt):
|
|
| 11 |
st.write(response)
|
| 12 |
gdf = as_geopandas(con, response)
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
if 'geometry' in gdf.columns:
|
| 15 |
m = leafmap.Map()
|
| 16 |
m.add_gdf(gdf)
|
|
@@ -32,7 +36,7 @@ def as_geopandas(con, response):
|
|
| 32 |
if 'geometry' in gdf.columns:
|
| 33 |
gdf = (gdf
|
| 34 |
.cast({"geometry": "geometry"})
|
| 35 |
-
.mutate(geometry = _.geometry.convert("EPSG:4326", "EPSG:4326"))
|
| 36 |
.to_pandas()
|
| 37 |
).set_crs(epsg=4326, inplace=True)
|
| 38 |
else:
|
|
|
|
| 11 |
st.write(response)
|
| 12 |
gdf = as_geopandas(con, response)
|
| 13 |
|
| 14 |
+
if len(gdf) == 0:
|
| 15 |
+
st.write("No results found.")
|
| 16 |
+
return
|
| 17 |
+
|
| 18 |
if 'geometry' in gdf.columns:
|
| 19 |
m = leafmap.Map()
|
| 20 |
m.add_gdf(gdf)
|
|
|
|
| 36 |
if 'geometry' in gdf.columns:
|
| 37 |
gdf = (gdf
|
| 38 |
.cast({"geometry": "geometry"})
|
| 39 |
+
# .mutate(geometry = _.geometry.convert("EPSG:4326", "EPSG:4326"))
|
| 40 |
.to_pandas()
|
| 41 |
).set_crs(epsg=4326, inplace=True)
|
| 42 |
else:
|