NaimaAqeel commited on
Commit
70fd172
·
verified ·
1 Parent(s): 6e6d28c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -76,16 +76,11 @@ else:
76
  def upload_files(files):
77
  global index, document_texts
78
  try:
79
- for file in files:
80
- content = file.read()
81
- if file.name.endswith('.pdf'):
82
- with open("temp.pdf", "wb") as f:
83
- f.write(content)
84
- text = extract_text_from_pdf("temp.pdf")
85
- elif file.name.endswith('.docx'):
86
- with open("temp.docx", "wb") as f:
87
- f.write(content)
88
- text = extract_text_from_docx("temp.docx")
89
  else:
90
  return "Unsupported file format"
91
 
@@ -148,6 +143,7 @@ demo.launch()
148
 
149
 
150
 
 
151
 
152
 
153
 
 
76
  def upload_files(files):
77
  global index, document_texts
78
  try:
79
+ for file_path in files:
80
+ if file_path.endswith('.pdf'):
81
+ text = extract_text_from_pdf(file_path)
82
+ elif file_path.endswith('.docx'):
83
+ text = extract_text_from_docx(file_path)
 
 
 
 
 
84
  else:
85
  return "Unsupported file format"
86
 
 
143
 
144
 
145
 
146
+
147
 
148
 
149