clementsan commited on
Commit
32a58be
1 Parent(s): 3bf3580

Remove potential spaces in collection_name

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -152,16 +152,19 @@ def initialize_llmchain(llm_model, temperature, max_tokens, top_k, vector_db, pr
152
  # Initialize database
153
  def initialize_database(list_file_obj, chunk_size, chunk_overlap, progress=gr.Progress()):
154
  # Create list of documents (when valid)
155
- #file_path = file_obj.name
156
  list_file_path = [x.name for x in list_file_obj if x is not None]
 
 
157
  collection_name = Path(list_file_path[0]).stem
 
 
158
  collection_name = collection_name[:50]
159
  # print('list_file_path: ', list_file_path)
160
- # print('Collection name: ', collection_name)
161
  progress(0.25, desc="Loading document...")
162
  # Load document and create splits
163
  doc_splits = load_doc(list_file_path, chunk_size, chunk_overlap)
164
- # Create or load Vector database
165
  progress(0.5, desc="Generating vector database...")
166
  # global vector_db
167
  vector_db = create_db(doc_splits, collection_name)
 
152
  # Initialize database
153
  def initialize_database(list_file_obj, chunk_size, chunk_overlap, progress=gr.Progress()):
154
  # Create list of documents (when valid)
 
155
  list_file_path = [x.name for x in list_file_obj if x is not None]
156
+ # Create collection_name for vector database
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...")
165
  # Load document and create splits
166
  doc_splits = load_doc(list_file_path, chunk_size, chunk_overlap)
167
+ # Create or load vector database
168
  progress(0.5, desc="Generating vector database...")
169
  # global vector_db
170
  vector_db = create_db(doc_splits, collection_name)