Spaces:
GIZ
/
Running on CPU Upgrade

Romulan12 commited on
Commit
b4cbbe0
·
verified ·
1 Parent(s): 9fb20e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -51
app.py CHANGED
@@ -1,8 +1,6 @@
1
  import gradio as gr
2
  import time
3
- import json
4
  from uuid import uuid4
5
- /# from utils.main_processor import get_statistics
6
 
7
  # Sample questions for examples
8
  SAMPLE_QUESTIONS = {
@@ -24,36 +22,11 @@ SAMPLE_QUESTIONS = {
24
  }
25
 
26
  def handle_geojson_upload(file):
27
- """Handle GeoJSON file upload and process with API"""
28
  if file is not None:
29
- try:
30
- # Call the API to get statistics
31
- # stats_result = get_statistics(file)
32
-
33
- # Create success message with API results
34
- success_message = "✅ Document submitted and processed successfully! You can now ask questions about this GeoJSON file."
35
-
36
- return (
37
- success_message,
38
- gr.update(visible=True), # upload_status
39
- stats_result, # api_results_df
40
- gr.update(visible=True) # results_section
41
- )
42
- except Exception as e:
43
- error_message = f"❌ Error processing file: {str(e)}"
44
- return (
45
- error_message,
46
- gr.update(visible=True), # upload_status
47
- None, # api_results_df
48
- gr.update(visible=False) # results_section
49
- )
50
  else:
51
- return (
52
- "❌ Please select a GeoJSON file to upload.",
53
- gr.update(visible=True), # upload_status
54
- None, # api_results_df
55
- gr.update(visible=False) # results_section
56
- )
57
 
58
  def start_chat(query, history):
59
  """Start a new chat interaction"""
@@ -195,15 +168,6 @@ with gr.Blocks(title="EUDR Q&A", theme=theme, css="style.css") as demo:
195
  )
196
  submit_file_btn = gr.Button("Submit GeoJSON", variant="primary")
197
  upload_status = gr.Markdown("", visible=False)
198
-
199
- # API Results Section
200
- with gr.Group(visible=False) as results_section:
201
- gr.Markdown("### Analysis Results")
202
- api_results_df = gr.Dataframe(
203
- label="Statistics from API",
204
- interactive=False,
205
- wrap=True
206
- )
207
 
208
  # Talk to Reports Section
209
  with gr.Group(visible=False) as reports_section:
@@ -273,14 +237,6 @@ with gr.Blocks(title="EUDR Q&A", theme=theme, css="style.css") as demo:
273
  - Ask one question at a time for clearer answers
274
  - Use follow-up questions to explore topics deeper
275
  - Provide context when possible
276
-
277
- ## 📊 API Analysis
278
-
279
- When you upload a GeoJSON file, our system automatically processes it through our analysis API to provide:
280
- - Statistical analysis of the geographic area
281
- - Deforestation risk assessment
282
- - Compliance indicators
283
- - Area calculations and boundaries
284
  """)
285
 
286
  # About Tab
@@ -302,7 +258,6 @@ with gr.Blocks(title="EUDR Q&A", theme=theme, css="style.css") as demo:
302
 
303
  ### Key Features:
304
  - Interactive analysis of uploaded GeoJSON files
305
- - Automated statistical analysis via API integration
306
  - Country-specific EUDR compliance guidance
307
  - Real-time question answering with source citations
308
  - User-friendly interface for complex regulatory information
@@ -320,7 +275,6 @@ with gr.Blocks(title="EUDR Q&A", theme=theme, css="style.css") as demo:
320
 
321
  ⚠️ **Data & Privacy:**
322
  - Uploaded GeoJSON files are processed temporarily for analysis
323
- - Files are sent to our analysis API for statistical processing
324
  - We collect usage statistics to improve the tool
325
  - No sensitive geographic data is permanently stored
326
 
@@ -344,11 +298,11 @@ with gr.Blocks(title="EUDR Q&A", theme=theme, css="style.css") as demo:
344
  outputs=[geojson_section, reports_section, dropdown_country]
345
  )
346
 
347
- # File upload with API integration
348
  submit_file_btn.click(
349
  fn=handle_geojson_upload,
350
  inputs=[uploaded_file],
351
- outputs=[upload_status, upload_status, api_results_df, results_section]
352
  )
353
 
354
  # Chat functionality
 
1
  import gradio as gr
2
  import time
 
3
  from uuid import uuid4
 
4
 
5
  # Sample questions for examples
6
  SAMPLE_QUESTIONS = {
 
22
  }
23
 
24
  def handle_geojson_upload(file):
25
+ """Handle GeoJSON file upload"""
26
  if file is not None:
27
+ return "✅ Document submitted successfully! You can now ask questions about this GeoJSON file.", gr.update(visible=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  else:
29
+ return "❌ Please select a GeoJSON file to upload.", gr.update(visible=True)
 
 
 
 
 
30
 
31
  def start_chat(query, history):
32
  """Start a new chat interaction"""
 
168
  )
169
  submit_file_btn = gr.Button("Submit GeoJSON", variant="primary")
170
  upload_status = gr.Markdown("", visible=False)
 
 
 
 
 
 
 
 
 
171
 
172
  # Talk to Reports Section
173
  with gr.Group(visible=False) as reports_section:
 
237
  - Ask one question at a time for clearer answers
238
  - Use follow-up questions to explore topics deeper
239
  - Provide context when possible
 
 
 
 
 
 
 
 
240
  """)
241
 
242
  # About Tab
 
258
 
259
  ### Key Features:
260
  - Interactive analysis of uploaded GeoJSON files
 
261
  - Country-specific EUDR compliance guidance
262
  - Real-time question answering with source citations
263
  - User-friendly interface for complex regulatory information
 
275
 
276
  ⚠️ **Data & Privacy:**
277
  - Uploaded GeoJSON files are processed temporarily for analysis
 
278
  - We collect usage statistics to improve the tool
279
  - No sensitive geographic data is permanently stored
280
 
 
298
  outputs=[geojson_section, reports_section, dropdown_country]
299
  )
300
 
301
+ # File upload
302
  submit_file_btn.click(
303
  fn=handle_geojson_upload,
304
  inputs=[uploaded_file],
305
+ outputs=[upload_status, upload_status]
306
  )
307
 
308
  # Chat functionality