Spaces:
GIZ
/
Running on CPU Upgrade

Romulan12 commited on
Commit
a4b0a09
·
1 Parent(s): a1c7621

add retriever call

Browse files
Files changed (1) hide show
  1. app.py +21 -10
app.py CHANGED
@@ -97,27 +97,38 @@ def handle_geojson_upload(file):
97
  gr.update(visible=False) # results_table
98
  )
99
 
100
- def retrieve_paragraphs(file):
101
  """Connect to retriever and retrieve paragraphs"""
102
  if file is not None:
103
  try:
104
  # Initialize WHISP API client
105
- client = Client("https://g...content-available-to-author-only...f.space/")
106
 
107
  # Call the API with the uploaded file
108
  result = client.predict(
109
- file=handle_file(file.name),
110
  api_name="/retrieve"
111
  )
112
 
113
- # Convert result to DataFrame
114
- df = pd.DataFrame(result['data'], columns=result['headers'])
115
- return df
116
-
 
 
117
  except Exception as e:
118
- print(f"Error retrieving paragraphs: {str(e)}")
119
- return None
120
- return None
 
 
 
 
 
 
 
 
 
121
 
122
  def start_chat(query, history):
123
  """Start a new chat interaction"""
 
97
  gr.update(visible=False) # results_table
98
  )
99
 
100
+ def retrieve_paragraphs(query):
101
  """Connect to retriever and retrieve paragraphs"""
102
  if file is not None:
103
  try:
104
  # Initialize WHISP API client
105
+ client = Client("https://giz-eudr-retriever.hf.space/")
106
 
107
  # Call the API with the uploaded file
108
  result = client.predict(
109
+ query=query,
110
  api_name="/retrieve"
111
  )
112
 
113
+ return (
114
+ results, # Keep formatted statistics for chat
115
+ gr.update(visible=True), # Keep status visible
116
+ gr.update(visible=False) # Always hide results table
117
+ )
118
+
119
  except Exception as e:
120
+ error_msg=(f"Error retrieving paragraphs: {str(e)}")
121
+ return (
122
+ error_msg,
123
+ gr.update(visible=True), # upload_status
124
+ gr.update(visible=False) # results_table
125
+ )
126
+ else:
127
+ return (
128
+ "",
129
+ gr.update(visible=False), # upload_status
130
+ gr.update(visible=False) # results_table
131
+ )
132
 
133
  def start_chat(query, history):
134
  """Start a new chat interaction"""