Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -251,18 +251,18 @@ class AdvancedRAG:
|
|
| 251 |
file=file_obj,
|
| 252 |
purpose="assistants"
|
| 253 |
)
|
| 254 |
-
self.file_ids
|
| 255 |
# Create a new thread for the new document
|
| 256 |
thread = openai.beta.threads.create()
|
| 257 |
self.thread_id = thread.id
|
| 258 |
-
#
|
| 259 |
openai.beta.threads.messages.create(
|
| 260 |
thread_id=self.thread_id,
|
| 261 |
role="user",
|
| 262 |
content="I have uploaded a document. Please analyze it.",
|
| 263 |
-
attachments=[{"file_id":
|
| 264 |
)
|
| 265 |
-
return
|
| 266 |
except Exception as e:
|
| 267 |
raise Exception(f"Error uploading document: {str(e)}")
|
| 268 |
|
|
|
|
| 251 |
file=file_obj,
|
| 252 |
purpose="assistants"
|
| 253 |
)
|
| 254 |
+
self.file_ids = [file_obj.id] # Only the new file
|
| 255 |
# Create a new thread for the new document
|
| 256 |
thread = openai.beta.threads.create()
|
| 257 |
self.thread_id = thread.id
|
| 258 |
+
# Send a message in the new thread with only the new file as an attachment
|
| 259 |
openai.beta.threads.messages.create(
|
| 260 |
thread_id=self.thread_id,
|
| 261 |
role="user",
|
| 262 |
content="I have uploaded a document. Please analyze it.",
|
| 263 |
+
attachments=[{"file_id": self.file_ids[0], "tools": [{"type": "file_search"}]}]
|
| 264 |
)
|
| 265 |
+
return self.file_ids[0]
|
| 266 |
except Exception as e:
|
| 267 |
raise Exception(f"Error uploading document: {str(e)}")
|
| 268 |
|