acpotts commited on
Commit
3042f59
1 Parent(s): 9c91a1d

Edit suffix in process_text_file()

Browse files
Files changed (1) hide show
  1. app.py +1 -2
app.py CHANGED
@@ -54,7 +54,7 @@ text_splitter = CharacterTextSplitter()
54
  def process_text_file(file: AskFileResponse):
55
  import tempfile
56
 
57
- with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".txt") as temp_file:
58
  temp_file_path = temp_file.name
59
 
60
  with open(temp_file_path, "wb") as f:
@@ -63,7 +63,6 @@ def process_text_file(file: AskFileResponse):
63
  if file.type == 'text/plain':
64
  text_loader = TextFileLoader(temp_file_path)
65
  documents = text_loader.load_documents()
66
-
67
  elif file.type == 'application/pdf':
68
  pdf_reader = PdfReader(temp_file_path)
69
  documents = [page.extract_text() for page in pdf_reader.pages]
 
54
  def process_text_file(file: AskFileResponse):
55
  import tempfile
56
 
57
+ with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=file.name) as temp_file:
58
  temp_file_path = temp_file.name
59
 
60
  with open(temp_file_path, "wb") as f:
 
63
  if file.type == 'text/plain':
64
  text_loader = TextFileLoader(temp_file_path)
65
  documents = text_loader.load_documents()
 
66
  elif file.type == 'application/pdf':
67
  pdf_reader = PdfReader(temp_file_path)
68
  documents = [page.extract_text() for page in pdf_reader.pages]