Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -99,11 +99,10 @@ def calculate_statistics(embeddings):
|
|
| 99 |
# Return time taken, token count, etc.
|
| 100 |
return {"tokens": len(embeddings), "time_taken": time.time()}
|
| 101 |
|
| 102 |
-
# Gradio frontend
|
| 103 |
def upload_file(file, model_name, split_strategy, chunk_size, overlap_size, max_tokens, query, top_k):
|
| 104 |
-
# Write the file using file.
|
| 105 |
with open(os.path.join(FILES_DIR, file.name), "wb") as f:
|
| 106 |
-
f.write(file.
|
| 107 |
|
| 108 |
# Process files and get embeddings
|
| 109 |
embeddings, chunks = process_files(model_name, split_strategy, chunk_size, overlap_size, max_tokens)
|
|
@@ -116,7 +115,6 @@ def upload_file(file, model_name, split_strategy, chunk_size, overlap_size, max_
|
|
| 116 |
|
| 117 |
return {"results": results, "stats": stats}
|
| 118 |
|
| 119 |
-
|
| 120 |
# Gradio interface
|
| 121 |
iface = gr.Interface(
|
| 122 |
fn=upload_file,
|
|
|
|
| 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 |
+
# 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(file.read()) # Use .read() to get the file content
|
| 106 |
|
| 107 |
# Process files and get embeddings
|
| 108 |
embeddings, chunks = process_files(model_name, split_strategy, chunk_size, overlap_size, max_tokens)
|
|
|
|
| 115 |
|
| 116 |
return {"results": results, "stats": stats}
|
| 117 |
|
|
|
|
| 118 |
# Gradio interface
|
| 119 |
iface = gr.Interface(
|
| 120 |
fn=upload_file,
|