clementsan commited on
Commit
6803339
1 Parent(s): 04361a6

Enforce alphanumeric character condition for collection name

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -21,6 +21,7 @@ import tqdm
21
  import accelerate
22
 
23
 
 
24
  # default_persist_directory = './chroma_HF/'
25
  list_llm = ["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mistral-7B-Instruct-v0.2", "mistralai/Mistral-7B-Instruct-v0.1", \
26
  "HuggingFaceH4/zephyr-7b-beta", "meta-llama/Llama-2-7b-chat-hf", "microsoft/phi-2", \
@@ -157,8 +158,15 @@ def initialize_database(list_file_obj, chunk_size, chunk_overlap, progress=gr.Pr
157
  progress(0.1, desc="Creating collection name...")
158
  collection_name = Path(list_file_path[0]).stem
159
  # Fix potential issues from naming convention
 
160
  collection_name = collection_name.replace(" ","-")
 
161
  collection_name = collection_name[:50]
 
 
 
 
 
162
  # print('list_file_path: ', list_file_path)
163
  print('Collection name: ', collection_name)
164
  progress(0.25, desc="Loading document...")
 
21
  import accelerate
22
 
23
 
24
+
25
  # default_persist_directory = './chroma_HF/'
26
  list_llm = ["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mistral-7B-Instruct-v0.2", "mistralai/Mistral-7B-Instruct-v0.1", \
27
  "HuggingFaceH4/zephyr-7b-beta", "meta-llama/Llama-2-7b-chat-hf", "microsoft/phi-2", \
 
158
  progress(0.1, desc="Creating collection name...")
159
  collection_name = Path(list_file_path[0]).stem
160
  # Fix potential issues from naming convention
161
+ ## Remove space
162
  collection_name = collection_name.replace(" ","-")
163
+ ## Limit lenght to 50 characters
164
  collection_name = collection_name[:50]
165
+ ## Enforce start and end as alphanumeric character
166
+ if not collection_name[0].isalnum():
167
+ collection_name[0] = 'A'
168
+ if not collection_name[-1].isalnum():
169
+ collection_name[-1] = 'Z'
170
  # print('list_file_path: ', list_file_path)
171
  print('Collection name: ', collection_name)
172
  progress(0.25, desc="Loading document...")