|
from langchain_community.document_loaders.csv_loader import CSVLoader |
|
from langchain.text_splitter import CharacterTextSplitter |
|
from langchain_openai import OpenAIEmbeddings |
|
from langchain_community.vectorstores.faiss import FAISS |
|
from dotenv import load_dotenv |
|
from langchain.document_loaders import WebBaseLoader |
|
|
|
load_dotenv(); |
|
|
|
documents = WebBaseLoader("https://rise.mmu.ac.uk/what-is-rise/").load() |
|
|
|
|
|
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=30) |
|
docs = text_splitter.split_documents(documents=documents) |
|
|
|
embeddings = OpenAIEmbeddings() |
|
|
|
vectorstore = FAISS.from_documents(docs, embeddings) |
|
|
|
vectorstore.save_local("_rise_faq_db"); |