Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
add retriever call
Browse files
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(
|
101 |
"""Connect to retriever and retrieve paragraphs"""
|
102 |
if file is not None:
|
103 |
try:
|
104 |
# Initialize WHISP API client
|
105 |
-
client = Client("https://
|
106 |
|
107 |
# Call the API with the uploaded file
|
108 |
result = client.predict(
|
109 |
-
|
110 |
api_name="/retrieve"
|
111 |
)
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
|
|
|
|
117 |
except Exception as e:
|
118 |
-
|
119 |
-
return
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"""
|