File size: 437 Bytes
229b183
7012e3b
 
3bc9c63
b727ef9
 
 
 
 
3bc9c63
 
 
b727ef9
3bc9c63
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from langchain_community.vectorstores import FAISS
from langchain_community.embeddings import HuggingFaceEmbeddings

def create_vectorstore(documents):
    if not documents:
        raise ValueError(
            "No valid source code found to build vector index."
        )

    embeddings = HuggingFaceEmbeddings(
        model_name="sentence-transformers/all-MiniLM-L6-v2"
    )

    return FAISS.from_documents(documents, embeddings)