Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -173,9 +173,7 @@ def search(query: str, k: int):
|
|
| 173 |
k (int): Number of top results to return (1–10).
|
| 174 |
|
| 175 |
Returns:
|
| 176 |
-
|
| 177 |
-
- results (list[tuple[PIL.Image.Image, str]]): List of (page_image, caption) pairs for a gallery.
|
| 178 |
-
- ai_response (str): Answer grounded only in retrieved pages, with citations (page numbers).
|
| 179 |
|
| 180 |
Notes:
|
| 181 |
• Requires that a PDF has been indexed first.
|
|
@@ -208,7 +206,7 @@ def search(query: str, k: int):
|
|
| 208 |
|
| 209 |
# Generate grounded response
|
| 210 |
ai_response = query_gpt(query, results)
|
| 211 |
-
return
|
| 212 |
|
| 213 |
|
| 214 |
# -----------------------------
|
|
@@ -269,13 +267,12 @@ This demo lets you **upload a PDF or load a sample**, then **search** for the mo
|
|
| 269 |
query = gr.Textbox(placeholder="Enter your query here", label="Query")
|
| 270 |
k_slider = gr.Slider(minimum=1, maximum=10, step=1, label="Number of results", value=5)
|
| 271 |
search_button = gr.Button("🔍 Search", variant="primary")
|
| 272 |
-
output_gallery = gr.Gallery(label="Retrieved Pages", height=600, show_label=True)
|
| 273 |
output_text = gr.Textbox(label="AI Response", placeholder="Generated response based on retrieved documents")
|
| 274 |
|
| 275 |
# Wiring
|
| 276 |
index_btn.click(handle_upload, inputs=[pdf_input], outputs=[status_box, pdf_view])
|
| 277 |
index_url_btn.click(handle_url, inputs=[url_box], outputs=[status_box, pdf_view])
|
| 278 |
-
search_button.click(search, inputs=[query, k_slider], outputs=[
|
| 279 |
|
| 280 |
if __name__ == "__main__":
|
| 281 |
# Optional: pre-load the default sample at startup.
|
|
|
|
| 173 |
k (int): Number of top results to return (1–10).
|
| 174 |
|
| 175 |
Returns:
|
| 176 |
+
ai_response (str): Answer grounded only in retrieved pages, with citations (page numbers).
|
|
|
|
|
|
|
| 177 |
|
| 178 |
Notes:
|
| 179 |
• Requires that a PDF has been indexed first.
|
|
|
|
| 206 |
|
| 207 |
# Generate grounded response
|
| 208 |
ai_response = query_gpt(query, results)
|
| 209 |
+
return ai_response
|
| 210 |
|
| 211 |
|
| 212 |
# -----------------------------
|
|
|
|
| 267 |
query = gr.Textbox(placeholder="Enter your query here", label="Query")
|
| 268 |
k_slider = gr.Slider(minimum=1, maximum=10, step=1, label="Number of results", value=5)
|
| 269 |
search_button = gr.Button("🔍 Search", variant="primary")
|
|
|
|
| 270 |
output_text = gr.Textbox(label="AI Response", placeholder="Generated response based on retrieved documents")
|
| 271 |
|
| 272 |
# Wiring
|
| 273 |
index_btn.click(handle_upload, inputs=[pdf_input], outputs=[status_box, pdf_view])
|
| 274 |
index_url_btn.click(handle_url, inputs=[url_box], outputs=[status_box, pdf_view])
|
| 275 |
+
search_button.click(search, inputs=[query, k_slider], outputs=[output_text])
|
| 276 |
|
| 277 |
if __name__ == "__main__":
|
| 278 |
# Optional: pre-load the default sample at startup.
|