| 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) | |