Spaces:
Running
Running
AamirAli123
commited on
Commit
•
c619e78
1
Parent(s):
c6c42c2
Update app.py
Browse files
app.py
CHANGED
@@ -150,17 +150,28 @@ def initialize_database(list_file_obj, chunk_size, chunk_overlap, vector_db, url
|
|
150 |
# Create collection_name for vector database
|
151 |
progress(0.1, desc="Creating collection name...")
|
152 |
collection_name = Path(list_file_path[0]).stem
|
|
|
153 |
# Fix potential issues from naming convention
|
154 |
-
## Remove
|
155 |
-
collection_name = collection_name.replace(" ","-")
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
157 |
collection_name = collection_name[:50]
|
158 |
-
|
|
|
159 |
if not collection_name[0].isalnum():
|
160 |
-
collection_name
|
|
|
|
|
161 |
if not collection_name[-1].isalnum():
|
162 |
-
collection_name[
|
163 |
-
|
|
|
|
|
164 |
print('Collection name: ', collection_name)
|
165 |
progress(0.25, desc="Loading document...")
|
166 |
# Load document and create splits
|
|
|
150 |
# Create collection_name for vector database
|
151 |
progress(0.1, desc="Creating collection name...")
|
152 |
collection_name = Path(list_file_path[0]).stem
|
153 |
+
|
154 |
# Fix potential issues from naming convention
|
155 |
+
## Remove spaces
|
156 |
+
collection_name = collection_name.replace(" ", "-")
|
157 |
+
|
158 |
+
## Ensure it meets the minimum length (3 characters)
|
159 |
+
if len(collection_name) < 3:
|
160 |
+
collection_name += "-XX" # Append extra characters if too short
|
161 |
+
|
162 |
+
## Limit the length to 50 characters
|
163 |
collection_name = collection_name[:50]
|
164 |
+
|
165 |
+
## Enforce that it starts with an alphanumeric character
|
166 |
if not collection_name[0].isalnum():
|
167 |
+
collection_name = 'A' + collection_name[1:]
|
168 |
+
|
169 |
+
## Enforce that it ends with an alphanumeric character
|
170 |
if not collection_name[-1].isalnum():
|
171 |
+
collection_name = collection_name[:-1] + 'Z'
|
172 |
+
|
173 |
+
# Print the collection name for verification
|
174 |
+
print('Collection name:', collection_name)
|
175 |
print('Collection name: ', collection_name)
|
176 |
progress(0.25, desc="Loading document...")
|
177 |
# Load document and create splits
|