AamirAli123 commited on
Commit
c619e78
1 Parent(s): c6c42c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -7
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 space
155
- collection_name = collection_name.replace(" ","-")
156
- ## Limit lenght to 50 characters
 
 
 
 
 
157
  collection_name = collection_name[:50]
158
- ## Enforce start and end as alphanumeric character
 
159
  if not collection_name[0].isalnum():
160
- collection_name[0] = 'A'
 
 
161
  if not collection_name[-1].isalnum():
162
- collection_name[-1] = 'Z'
163
- # print('list_file_path: ', list_file_path)
 
 
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