forked from open-webui/open-webui
		
	
						commit
						2f6e683163
					
				
					 1 changed files with 9 additions and 3 deletions
				
			
		|  | @ -15,6 +15,7 @@ from typing import List | ||||||
| 
 | 
 | ||||||
| from sentence_transformers import SentenceTransformer | from sentence_transformers import SentenceTransformer | ||||||
| from chromadb.utils import embedding_functions | from chromadb.utils import embedding_functions | ||||||
|  | from chromadb.utils.batch_utils import create_batches | ||||||
| 
 | 
 | ||||||
| from langchain_community.document_loaders import ( | from langchain_community.document_loaders import ( | ||||||
|     WebBaseLoader, |     WebBaseLoader, | ||||||
|  | @ -331,9 +332,14 @@ def store_docs_in_vector_db(docs, collection_name, overwrite: bool = False) -> b | ||||||
|             embedding_function=app.state.sentence_transformer_ef, |             embedding_function=app.state.sentence_transformer_ef, | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|         collection.add( |         for batch in create_batches( | ||||||
|             documents=texts, metadatas=metadatas, ids=[str(uuid.uuid1()) for _ in texts] |             api=CHROMA_CLIENT, | ||||||
|         ) |             ids=[str(uuid.uuid1()) for _ in texts], | ||||||
|  |             metadatas=metadatas, | ||||||
|  |             documents=texts, | ||||||
|  |         ): | ||||||
|  |             collection.add(*batch) | ||||||
|  | 
 | ||||||
|         return True |         return True | ||||||
|     except Exception as e: |     except Exception as e: | ||||||
|         log.exception(e) |         log.exception(e) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy Jaeryang Baek
						Timothy Jaeryang Baek