Commit ·
25ec7ce
1
Parent(s): e62a755
Increase upload timeout for large PDFs; add slow-indexing notice
Browse files
app.py
CHANGED
|
@@ -35,9 +35,14 @@ def upload_files(files) -> str:
|
|
| 35 |
path = f if isinstance(f, str) else f.name
|
| 36 |
with open(path, "rb") as fp:
|
| 37 |
multipart.append(("files", (os.path.basename(path), fp.read(), "application/octet-stream")))
|
| 38 |
-
|
|
|
|
|
|
|
| 39 |
resp.raise_for_status()
|
| 40 |
return resp.json().get("status", "Files processed.")
|
|
|
|
|
|
|
|
|
|
| 41 |
except requests.exceptions.RequestException as e:
|
| 42 |
return f"Upload failed: {e}"
|
| 43 |
|
|
@@ -191,7 +196,8 @@ with gr.Blocks(title="Agentic RAG Knowledge Search") as demo:
|
|
| 191 |
with gr.Group():
|
| 192 |
gr.Markdown(
|
| 193 |
f"### Upload Documents\n"
|
| 194 |
-
f"Supported: **{', '.join(SUPPORTED_TYPES)}** — multiple files allowed, new uploads add to the index."
|
|
|
|
| 195 |
)
|
| 196 |
file_input = gr.File(label="Select Files", file_count="multiple", file_types=SUPPORTED_TYPES)
|
| 197 |
with gr.Row():
|
|
|
|
| 35 |
path = f if isinstance(f, str) else f.name
|
| 36 |
with open(path, "rb") as fp:
|
| 37 |
multipart.append(("files", (os.path.basename(path), fp.read(), "application/octet-stream")))
|
| 38 |
+
# Large PDFs produce thousands of chunks; embedding them on CPU can take
|
| 39 |
+
# a few minutes, so allow a generous timeout.
|
| 40 |
+
resp = requests.post(UPLOAD_ENDPOINT, files=multipart, timeout=900)
|
| 41 |
resp.raise_for_status()
|
| 42 |
return resp.json().get("status", "Files processed.")
|
| 43 |
+
except requests.exceptions.ReadTimeout:
|
| 44 |
+
return ("Still indexing — this file is large and CPU embedding is slow. "
|
| 45 |
+
"Wait a moment and try your question; it may already be indexed.")
|
| 46 |
except requests.exceptions.RequestException as e:
|
| 47 |
return f"Upload failed: {e}"
|
| 48 |
|
|
|
|
| 196 |
with gr.Group():
|
| 197 |
gr.Markdown(
|
| 198 |
f"### Upload Documents\n"
|
| 199 |
+
f"Supported: **{', '.join(SUPPORTED_TYPES)}** — multiple files allowed, new uploads add to the index. \n"
|
| 200 |
+
"_Large PDFs (100s of pages) can take a few minutes to index on the free CPU — please be patient._"
|
| 201 |
)
|
| 202 |
file_input = gr.File(label="Select Files", file_count="multiple", file_types=SUPPORTED_TYPES)
|
| 203 |
with gr.Row():
|