INNER CODE UNIT · Python

docs2vectorstore

junruxiong/IncarnaMind · docs2db.py:96

def docs2vectorstore(docs: List[Document], embedding_name: str, suffix: str = ""):
    """Convert a list of Documents into a Chroma vector store.

    Args:
        docs (Document): The list of Documents.
        suffix (str, optional): Suffix for the embedding. Defaults to "".
    """
    embedding = choose_embeddings(embedding_name)
    name = f"{embedding_name}_{suffix}"
    # if embedding_store_path is not existing, create it
    if not os.path.exists(embedding_store_path):
        os.makedirs(embedding_store_path)
    Chroma.from_documents(
        docs,
        embedding,
        persist_directory=f"{embedding_store_path}/chroma_{name}",
    )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…