Chris4K commited on
Commit
b18d63d
1 Parent(s): fc7a81d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -99,12 +99,16 @@ def calculate_statistics(embeddings):
99
  # Return time taken, token count, etc.
100
  return {"tokens": len(embeddings), "time_taken": time.time()}
101
 
 
 
 
102
  def upload_file(file, model_name, split_strategy, chunk_size, overlap_size, max_tokens, query, top_k):
103
- fh = open(file, 'r')
104
- data = fh.readlines()
105
  # Write the file using file.read() instead of file.value
106
- with open(os.path.join(FILES_DIR, file.name), "wb") as f:
107
- f.write(data) # Use .read() to get the file content
 
108
 
109
  # Process files and get embeddings
110
  embeddings, chunks = process_files(model_name, split_strategy, chunk_size, overlap_size, max_tokens)
 
99
  # Return time taken, token count, etc.
100
  return {"tokens": len(embeddings), "time_taken": time.time()}
101
 
102
+ import shutil
103
+
104
+
105
  def upload_file(file, model_name, split_strategy, chunk_size, overlap_size, max_tokens, query, top_k):
106
+ #fh = open(file, 'r')
107
+ #data = fh.readlines()
108
  # Write the file using file.read() instead of file.value
109
+ #with open(os.path.join(FILES_DIR, file.name), "wb") as f:
110
+ # f.write(data) # Use .read() to get the file content
111
+ shutil.copyfile(file.name, FILES_DIR)
112
 
113
  # Process files and get embeddings
114
  embeddings, chunks = process_files(model_name, split_strategy, chunk_size, overlap_size, max_tokens)