Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
translate UI to Spanish
Browse files
app.py
CHANGED
@@ -43,21 +43,21 @@ async def chat_response(query, history, method, country, uploaded_file):
|
|
43 |
"""Generate chat response based on method and inputs"""
|
44 |
|
45 |
# Validate inputs
|
46 |
-
if method == "
|
47 |
if uploaded_file is None:
|
48 |
-
warning_message = "⚠️ **No
|
49 |
history[-1] = (query, warning_message)
|
50 |
yield history, ""
|
51 |
return
|
52 |
else: # "Talk to Reports"
|
53 |
if not country:
|
54 |
-
warning_message = "⚠️ **No
|
55 |
history[-1] = (query, warning_message)
|
56 |
yield history, ""
|
57 |
return
|
58 |
|
59 |
# Handle GeoJSON upload → put formatted stats into chat
|
60 |
-
if method == "
|
61 |
try:
|
62 |
# handle_geojson_upload returns a tuple (formatted_stats, gr.update(), gr.update())
|
63 |
stats_result = handle_geojson_upload(uploaded_file)
|
@@ -88,14 +88,14 @@ def auto_analyze_file(file, history):
|
|
88 |
"""Automatically analyze uploaded GeoJSON file and add results to chat"""
|
89 |
if file is not None:
|
90 |
# Add a system message indicating file upload
|
91 |
-
analysis_query = "📄 GeoJSON
|
92 |
history = history + [(analysis_query, None)]
|
93 |
return history, analysis_query
|
94 |
return history, ""
|
95 |
|
96 |
def auto_display_results(query, history, uploaded_file):
|
97 |
"""Display analysis results automatically after file upload"""
|
98 |
-
if uploaded_file is not None and query.startswith("📄 GeoJSON
|
99 |
try:
|
100 |
# Get the analysis results
|
101 |
stats_result = handle_geojson_upload(uploaded_file)
|
@@ -113,7 +113,7 @@ def auto_display_results(query, history, uploaded_file):
|
|
113 |
|
114 |
def toggle_search_method(method):
|
115 |
"""Toggle between GeoJSON upload and country selection"""
|
116 |
-
if method == "
|
117 |
return (
|
118 |
gr.update(visible=True), # geojson_section
|
119 |
gr.update(visible=False), # reports_section
|
@@ -174,20 +174,25 @@ custom_css = """
|
|
174 |
"""
|
175 |
|
176 |
init_prompt = """
|
177 |
-
|
|
|
|
|
|
|
178 |
|
179 |
-
💡 **
|
180 |
-
- **Data Sources**: Choose to either upload a GeoJSON file for analysis or talk to EUDR reports filtered by country.
|
181 |
-
- **Examples**: Select from curated example questions across different categories.
|
182 |
-
- **Sources**: View the content sources used to generate answers for fact-checking.
|
183 |
|
184 |
-
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
186 |
|
187 |
-
with gr.Blocks(title="EUDR
|
188 |
|
189 |
# Main Chat Interface
|
190 |
-
with gr.Tab("EUDR
|
191 |
with gr.Row():
|
192 |
# Left column - Chat interface (2/3 width)
|
193 |
with gr.Column(scale=2):
|
@@ -203,16 +208,16 @@ with gr.Blocks(title="EUDR Q&A", theme=theme, css=custom_css) as demo:
|
|
203 |
# Feedback UI
|
204 |
with gr.Column():
|
205 |
with gr.Row(visible=False) as feedback_row:
|
206 |
-
gr.Markdown("
|
207 |
with gr.Row():
|
208 |
-
okay_btn = gr.Button("👍
|
209 |
-
not_okay_btn = gr.Button("👎
|
210 |
-
feedback_thanks = gr.Markdown("
|
211 |
|
212 |
# Input textbox
|
213 |
with gr.Row():
|
214 |
textbox = gr.Textbox(
|
215 |
-
placeholder="
|
216 |
show_label=False,
|
217 |
scale=7,
|
218 |
lines=1,
|
@@ -224,18 +229,18 @@ with gr.Blocks(title="EUDR Q&A", theme=theme, css=custom_css) as demo:
|
|
224 |
with gr.Tabs() as tabs:
|
225 |
|
226 |
# Data Sources Tab
|
227 |
-
with gr.Tab("
|
228 |
search_method = gr.Radio(
|
229 |
-
choices=["
|
230 |
label="Choose data source",
|
231 |
info="Upload a GeoJSON file for analysis or select country-specific EUDR reports",
|
232 |
-
value="
|
233 |
)
|
234 |
|
235 |
# GeoJSON Upload Section
|
236 |
with gr.Group(visible=True) as geojson_section:
|
237 |
uploaded_file = gr.File(
|
238 |
-
label="
|
239 |
file_types=[".geojson", ".json"],
|
240 |
file_count="single"
|
241 |
)
|
|
|
43 |
"""Generate chat response based on method and inputs"""
|
44 |
|
45 |
# Validate inputs
|
46 |
+
if method == "Subir GeoJson":
|
47 |
if uploaded_file is None:
|
48 |
+
warning_message = "⚠️ **No se ha cargado ningún GeoJSON.** Por favor, carga primero un GeoJSON."
|
49 |
history[-1] = (query, warning_message)
|
50 |
yield history, ""
|
51 |
return
|
52 |
else: # "Talk to Reports"
|
53 |
if not country:
|
54 |
+
warning_message = "⚠️ **No se ha seleccionado ningún país.** Seleccione un país para analizar los informes."
|
55 |
history[-1] = (query, warning_message)
|
56 |
yield history, ""
|
57 |
return
|
58 |
|
59 |
# Handle GeoJSON upload → put formatted stats into chat
|
60 |
+
if method == "Subir GeoJson" and uploaded_file:
|
61 |
try:
|
62 |
# handle_geojson_upload returns a tuple (formatted_stats, gr.update(), gr.update())
|
63 |
stats_result = handle_geojson_upload(uploaded_file)
|
|
|
88 |
"""Automatically analyze uploaded GeoJSON file and add results to chat"""
|
89 |
if file is not None:
|
90 |
# Add a system message indicating file upload
|
91 |
+
analysis_query = "📄 GeoJSON cargado - analizando..."
|
92 |
history = history + [(analysis_query, None)]
|
93 |
return history, analysis_query
|
94 |
return history, ""
|
95 |
|
96 |
def auto_display_results(query, history, uploaded_file):
|
97 |
"""Display analysis results automatically after file upload"""
|
98 |
+
if uploaded_file is not None and query.startswith("📄 GeoJSON cargado"):
|
99 |
try:
|
100 |
# Get the analysis results
|
101 |
stats_result = handle_geojson_upload(uploaded_file)
|
|
|
113 |
|
114 |
def toggle_search_method(method):
|
115 |
"""Toggle between GeoJSON upload and country selection"""
|
116 |
+
if method == "Subir GeoJSON":
|
117 |
return (
|
118 |
gr.update(visible=True), # geojson_section
|
119 |
gr.update(visible=False), # reports_section
|
|
|
174 |
"""
|
175 |
|
176 |
init_prompt = """
|
177 |
+
Hola, soy EUDR Bot, un asistente conversacional basado en inteligencia artificial diseñado
|
178 |
+
para ayudarle a comprender el cumplimiento y el análisis del Reglamento de la UE sobre
|
179 |
+
la deforestación. Responderé a sus preguntas utilizando los informes EUDR y los archivos
|
180 |
+
GeoJSON cargados.
|
181 |
|
182 |
+
💡 **Cómo utilizarlo (pestañas a la derecha)**
|
|
|
|
|
|
|
183 |
|
184 |
+
**Fuentes de datos:** elige entre subir un archivo GeoJSON para su análisis o consultar los informes EUDR filtrados por país.
|
185 |
+
**Ejemplos:** selecciona entre preguntas de ejemplo seleccionadas de diferentes categorías.
|
186 |
+
**Fuentes:** consulta las fuentes de contenido utilizadas para generar respuestas para la verificación de datos.
|
187 |
+
|
188 |
+
⚠️ Para conocer las limitaciones y la información sobre la recopilación de datos, consulta la pestaña «Aviso legal».
|
189 |
+
|
190 |
+
"""
|
191 |
|
192 |
+
with gr.Blocks(title="EUDR Bot", theme=theme, css=custom_css) as demo:
|
193 |
|
194 |
# Main Chat Interface
|
195 |
+
with gr.Tab("EUDR Bot"):
|
196 |
with gr.Row():
|
197 |
# Left column - Chat interface (2/3 width)
|
198 |
with gr.Column(scale=2):
|
|
|
208 |
# Feedback UI
|
209 |
with gr.Column():
|
210 |
with gr.Row(visible=False) as feedback_row:
|
211 |
+
gr.Markdown("¿Te ha sido útil esta respuesta?")
|
212 |
with gr.Row():
|
213 |
+
okay_btn = gr.Button("👍 De acuerdo", size="sm")
|
214 |
+
not_okay_btn = gr.Button("👎 No según lo esperado", size="sm")
|
215 |
+
feedback_thanks = gr.Markdown("Gracias por los comentarios.", visible=False)
|
216 |
|
217 |
# Input textbox
|
218 |
with gr.Row():
|
219 |
textbox = gr.Textbox(
|
220 |
+
placeholder="¡Pregúntame cualquier cosa sobre el cumplimiento de la normativa EUDR o sube tu GeoJSON para su análisis!",
|
221 |
show_label=False,
|
222 |
scale=7,
|
223 |
lines=1,
|
|
|
229 |
with gr.Tabs() as tabs:
|
230 |
|
231 |
# Data Sources Tab
|
232 |
+
with gr.Tab("Fuentes de datos", id=2):
|
233 |
search_method = gr.Radio(
|
234 |
+
choices=["Subir GeoJson", "Talk to Reports"],
|
235 |
label="Choose data source",
|
236 |
info="Upload a GeoJSON file for analysis or select country-specific EUDR reports",
|
237 |
+
value="Subir GeoJson",
|
238 |
)
|
239 |
|
240 |
# GeoJSON Upload Section
|
241 |
with gr.Group(visible=True) as geojson_section:
|
242 |
uploaded_file = gr.File(
|
243 |
+
label="Subir GeoJson",
|
244 |
file_types=[".geojson", ".json"],
|
245 |
file_count="single"
|
246 |
)
|
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
|
|