Update app.py
Browse files
app.py
CHANGED
@@ -100,9 +100,11 @@ def calculate_statistics(embeddings):
|
|
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 |
# Write the file using file.read() instead of file.value
|
104 |
with open(os.path.join(FILES_DIR, file.name), "wb") as f:
|
105 |
-
f.write(
|
106 |
|
107 |
# Process files and get embeddings
|
108 |
embeddings, chunks = process_files(model_name, split_strategy, chunk_size, overlap_size, max_tokens)
|
|
|
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)
|