Update app.py
Browse files
app.py
CHANGED
@@ -109,15 +109,24 @@ def calculate_statistics(embeddings):
|
|
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
|
114 |
try:
|
115 |
-
chunk_size
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
except ValueError:
|
118 |
return {"error": "Chunk size and overlap size must be valid integers."}
|
119 |
|
120 |
-
# Handle file upload using
|
121 |
file_path = file.name # Get the file path from Gradio file object
|
122 |
|
123 |
# Copy the uploaded file content to a local directory
|
|
|
109 |
import shutil
|
110 |
|
111 |
|
112 |
+
import shutil
|
113 |
+
|
114 |
def upload_file(file, model_name, split_strategy, chunk_size, overlap_size, max_tokens, query, top_k):
|
115 |
+
# Ensure chunk_size and overlap_size are valid integers and provide defaults if needed
|
116 |
try:
|
117 |
+
if chunk_size is None or chunk_size == "":
|
118 |
+
chunk_size = 100 # Default value if not provided
|
119 |
+
else:
|
120 |
+
chunk_size = int(chunk_size) # Convert to int if valid
|
121 |
+
|
122 |
+
if overlap_size is None or overlap_size == "":
|
123 |
+
overlap_size = 0 # Default value if not provided
|
124 |
+
else:
|
125 |
+
overlap_size = int(overlap_size) # Convert to int if valid
|
126 |
except ValueError:
|
127 |
return {"error": "Chunk size and overlap size must be valid integers."}
|
128 |
|
129 |
+
# Handle file upload using Gradio file object
|
130 |
file_path = file.name # Get the file path from Gradio file object
|
131 |
|
132 |
# Copy the uploaded file content to a local directory
|