Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,13 +108,17 @@ def calculate_statistics(embeddings):
|
|
| 108 |
|
| 109 |
import shutil
|
| 110 |
|
|
|
|
| 111 |
def upload_file(file, model_name, split_strategy, chunk_size, overlap_size, max_tokens, query, top_k):
|
| 112 |
-
# Ensure
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
-
#
|
| 117 |
-
file_path = file.name # Get the file path from
|
| 118 |
|
| 119 |
# Copy the uploaded file content to a local directory
|
| 120 |
destination_path = os.path.join(FILES_DIR, os.path.basename(file_path))
|
|
@@ -131,6 +135,7 @@ def upload_file(file, model_name, split_strategy, chunk_size, overlap_size, max_
|
|
| 131 |
|
| 132 |
return {"results": results, "stats": stats}
|
| 133 |
|
|
|
|
| 134 |
# Gradio interface
|
| 135 |
iface = gr.Interface(
|
| 136 |
fn=upload_file,
|
|
|
|
| 108 |
|
| 109 |
import shutil
|
| 110 |
|
| 111 |
+
|
| 112 |
def upload_file(file, model_name, split_strategy, chunk_size, overlap_size, max_tokens, query, top_k):
|
| 113 |
+
# Ensure the correct type for chunk_size and overlap_size
|
| 114 |
+
try:
|
| 115 |
+
chunk_size = int(chunk_size) if chunk_size else 100
|
| 116 |
+
overlap_size = int(overlap_size) if overlap_size else 0
|
| 117 |
+
except ValueError:
|
| 118 |
+
return {"error": "Chunk size and overlap size must be valid integers."}
|
| 119 |
|
| 120 |
+
# Handle file upload using the Gradio file object
|
| 121 |
+
file_path = file.name # Get the file path from Gradio file object
|
| 122 |
|
| 123 |
# Copy the uploaded file content to a local directory
|
| 124 |
destination_path = os.path.join(FILES_DIR, os.path.basename(file_path))
|
|
|
|
| 135 |
|
| 136 |
return {"results": results, "stats": stats}
|
| 137 |
|
| 138 |
+
|
| 139 |
# Gradio interface
|
| 140 |
iface = gr.Interface(
|
| 141 |
fn=upload_file,
|