rag_agent / knowledge_base /embeddings.py
kith777's picture
first commit
067cdc9
raw
history blame
751 Bytes
from langchain_huggingface import HuggingFaceEmbeddings
from langchain_chroma import Chroma
# 1. Define the custom embedding object
dense_embeddings = HuggingFaceEmbeddings(
model_name="sentence-transformers/all-mpnet-base-v2"
)
# 2. Initialize the LangChain Chroma vector store, passing the embeddings
vectorstore = Chroma.from_documents(
documents=["./docs/markdowns"], # Placeholder for actual documents
embedding=dense_embeddings,
collection_name="langchain_mpnet_collection",
persist_directory="./knowledge_base/chroma_data"
)
# 3. Save the database (essential for persistence)
vectorstore.persist()
print("LangChain Chroma vector store created with custom embeddings and persisted.")
if __name__ == "__main__":
pass