Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -215,11 +215,14 @@ class AdvancedRAG:
|
|
| 215 |
if file is None:
|
| 216 |
raise ValueError("No file provided")
|
| 217 |
|
| 218 |
-
#
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
|
|
|
|
|
|
|
|
|
| 223 |
tmp.flush()
|
| 224 |
|
| 225 |
# Upload the file to OpenAI
|
|
@@ -395,7 +398,8 @@ with gr.Blocks(title="Document Q&A System", css=custom_css) as demo:
|
|
| 395 |
file_input = gr.File(
|
| 396 |
label="Upload Document",
|
| 397 |
file_types=[".pdf", ".txt", ".doc", ".docx"],
|
| 398 |
-
file_count="single"
|
|
|
|
| 399 |
)
|
| 400 |
file_output = gr.Textbox(
|
| 401 |
label="Upload Status",
|
|
|
|
| 215 |
if file is None:
|
| 216 |
raise ValueError("No file provided")
|
| 217 |
|
| 218 |
+
# The file is now a bytes object directly
|
| 219 |
+
file_bytes = file
|
| 220 |
+
if not file_bytes:
|
| 221 |
+
raise ValueError("Empty file")
|
| 222 |
+
|
| 223 |
+
# Create a temporary file with a generic extension
|
| 224 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".txt") as tmp:
|
| 225 |
+
tmp.write(file_bytes)
|
| 226 |
tmp.flush()
|
| 227 |
|
| 228 |
# Upload the file to OpenAI
|
|
|
|
| 398 |
file_input = gr.File(
|
| 399 |
label="Upload Document",
|
| 400 |
file_types=[".pdf", ".txt", ".doc", ".docx"],
|
| 401 |
+
file_count="single",
|
| 402 |
+
type="binary" # Specify that we want binary data
|
| 403 |
)
|
| 404 |
file_output = gr.Textbox(
|
| 405 |
label="Upload Status",
|