Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -233,7 +233,13 @@ class AdvancedRAG:
|
|
| 233 |
return self.thread_id
|
| 234 |
|
| 235 |
def upload_document(self, file) -> str:
|
| 236 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
self.thread_id = None
|
| 238 |
self.file_ids = []
|
| 239 |
if hasattr(self, 'vector_store_id'):
|
|
|
|
| 233 |
return self.thread_id
|
| 234 |
|
| 235 |
def upload_document(self, file) -> str:
|
| 236 |
+
# Delete previous file from OpenAI if it exists
|
| 237 |
+
if self.file_ids:
|
| 238 |
+
for file_id in self.file_ids:
|
| 239 |
+
try:
|
| 240 |
+
openai.files.delete(file_id)
|
| 241 |
+
except Exception as e:
|
| 242 |
+
print(f"Warning: Could not delete file {file_id}: {e}")
|
| 243 |
self.thread_id = None
|
| 244 |
self.file_ids = []
|
| 245 |
if hasattr(self, 'vector_store_id'):
|