Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
add deforestation before 2020
Browse files
utils/__pycache__/generator.cpython-310.pyc
CHANGED
Binary files a/utils/__pycache__/generator.cpython-310.pyc and b/utils/__pycache__/generator.cpython-310.pyc differ
|
|
utils/__pycache__/retriever.cpython-310.pyc
CHANGED
Binary files a/utils/__pycache__/retriever.cpython-310.pyc and b/utils/__pycache__/retriever.cpython-310.pyc differ
|
|
utils/__pycache__/whisp_api.cpython-310.pyc
CHANGED
Binary files a/utils/__pycache__/whisp_api.cpython-310.pyc and b/utils/__pycache__/whisp_api.cpython-310.pyc differ
|
|
utils/whisp_api.py
CHANGED
@@ -20,10 +20,10 @@ def format_whisp_statistics(df):
|
|
20 |
'ECU': 'Ecuador',
|
21 |
'COL': 'Colombia',
|
22 |
'PER': 'Peru',
|
23 |
-
'BRA': '
|
24 |
'BOL': 'Bolivia',
|
25 |
'CRI': 'Costa Rica',
|
26 |
-
'PAN': '
|
27 |
'NIC': 'Nicaragua'
|
28 |
}
|
29 |
|
@@ -49,6 +49,7 @@ def format_whisp_statistics(df):
|
|
49 |
risk_acrop = get_value(df, "risk_acrop")
|
50 |
risk_timber = get_value(df, "risk_timber")
|
51 |
def_after_2020_raw = get_value(df, "TMF_def_after_2020")
|
|
|
52 |
|
53 |
# Helper function to format risk levels with colors/emojis
|
54 |
def format_risk(risk_val):
|
@@ -77,27 +78,29 @@ def format_whisp_statistics(df):
|
|
77 |
try:
|
78 |
def_num = float(def_val)
|
79 |
if def_num == 0:
|
80 |
-
return "* 馃尦 No se detect贸 deforestaci贸n
|
81 |
elif def_num < 0.1:
|
82 |
-
return f"馃尦 *{def_num:.3f} hect谩reas de deforestaci贸n
|
83 |
else:
|
84 |
-
return f" 馃尦*{def_num:.2f} hect谩reas de deforestaci贸n
|
85 |
except:
|
86 |
return f"鈩癸笍 **{def_val}**"
|
87 |
|
88 |
-
# Create EUDR compliance assessment
|
89 |
-
def get_compliance_status(def_after_2020):
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
98 |
|
99 |
-
|
100 |
-
compliance_status = get_compliance_status(def_after_2020_raw)
|
101 |
|
102 |
output = f""" **Respuesta generada mediante inteligencia artific铆al:** \n\n
|
103 |
|
@@ -121,7 +124,8 @@ La siguiente informaci贸n ha sido generada por la [WhispAPI creada por Forest Da
|
|
121 |
- {format_risk(risk_timber)} \n\n
|
122 |
|
123 |
**Deforestaci贸n reciente (2020-presente):** \n\n
|
124 |
-
- {
|
|
|
125 |
|
126 |
"""
|
127 |
return output
|
|
|
20 |
'ECU': 'Ecuador',
|
21 |
'COL': 'Colombia',
|
22 |
'PER': 'Peru',
|
23 |
+
'BRA': 'Brasil',
|
24 |
'BOL': 'Bolivia',
|
25 |
'CRI': 'Costa Rica',
|
26 |
+
'PAN': 'Panam谩',
|
27 |
'NIC': 'Nicaragua'
|
28 |
}
|
29 |
|
|
|
49 |
risk_acrop = get_value(df, "risk_acrop")
|
50 |
risk_timber = get_value(df, "risk_timber")
|
51 |
def_after_2020_raw = get_value(df, "TMF_def_after_2020")
|
52 |
+
def_before_2020_raw = get_value(df, "TMF_def_before_2020")
|
53 |
|
54 |
# Helper function to format risk levels with colors/emojis
|
55 |
def format_risk(risk_val):
|
|
|
78 |
try:
|
79 |
def_num = float(def_val)
|
80 |
if def_num == 0:
|
81 |
+
return "* 馃尦 No se detect贸 deforestaci贸n.*"
|
82 |
elif def_num < 0.1:
|
83 |
+
return f"馃尦 *{def_num:.3f} hect谩reas de deforestaci贸n*"
|
84 |
else:
|
85 |
+
return f" 馃尦*{def_num:.2f} hect谩reas de deforestaci贸n*"
|
86 |
except:
|
87 |
return f"鈩癸笍 **{def_val}**"
|
88 |
|
89 |
+
# # Create EUDR compliance assessment
|
90 |
+
# def get_compliance_status(def_after_2020):
|
91 |
+
# try:
|
92 |
+
# def_num = float(def_after_2020)
|
93 |
+
# if def_num == 0:
|
94 |
+
# return "**No se detect贸 deforestaci贸n despu茅s de 2020.**"
|
95 |
+
# elif def_num > 0:
|
96 |
+
# return "**Deforestaci贸n reciente detectada**"
|
97 |
+
# except:
|
98 |
+
# return "**Datos insuficientes para determinar el cumplimiento"
|
99 |
+
|
100 |
+
deforestation_after_2020_formatted = format_deforestation(def_after_2020_raw)
|
101 |
+
deforestation_before_2020_formatted = format_deforestation(def_before_2020_raw)
|
102 |
|
103 |
+
# compliance_status = get_compliance_status(def_after_2020_raw)
|
|
|
104 |
|
105 |
output = f""" **Respuesta generada mediante inteligencia artific铆al:** \n\n
|
106 |
|
|
|
124 |
- {format_risk(risk_timber)} \n\n
|
125 |
|
126 |
**Deforestaci贸n reciente (2020-presente):** \n\n
|
127 |
+
- {deforestation_before_2020_formatted} detectadas antes de 2020. \n\n
|
128 |
+
- {deforestation_after_2020_formatted} detectadas despu茅s de 2020. \n\n
|
129 |
|
130 |
"""
|
131 |
return output
|