Download core/vector_store.py from Salahin/Chat-PDF: direct link, hf CLI and curl.
- Browser
- Download file 470 Bytes
-
https://huggingface.co/spaces/Salahin/Chat-PDF/resolve/main/core/vector_store.py
- Command line
-
hf download hf://spaces/Salahin/Chat-PDF/core/vector_store.py
-
curl -L -o vector_store.py https://huggingface.co/spaces/Salahin/Chat-PDF/resolve/main/core/vector_store.py
470 Bytes
| import streamlit as st | |
| from langchain_google_genai import GoogleGenerativeAIEmbeddings | |
| from langchain_community.vectorstores import FAISS | |
| def get_vector_store(text_chunks): | |
| try: | |
| embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001") | |
| vector_store = FAISS.from_texts(text_chunks, embedding=embeddings) | |
| vector_store.save_local("data/faiss_index") | |
| except Exception as e: | |
| st.error(f"Error creating FAISS index: {e}") | |