DreamStream-1 commited on
Commit
d008c8e
·
verified ·
1 Parent(s): b8b7b8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -251,18 +251,18 @@ class AdvancedRAG:
251
  file=file_obj,
252
  purpose="assistants"
253
  )
254
- self.file_ids.append(file_obj.id)
255
  # Create a new thread for the new document
256
  thread = openai.beta.threads.create()
257
  self.thread_id = thread.id
258
- # Add the file to the thread
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": file_obj.id, "tools": [{"type": "file_search"}]}]
264
  )
265
- return file_obj.id
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