Untitled
unknown
plain_text
2 years ago
665 B
12
Indexable
# Embed chunks
@st.cache_data
def embed_chunks(chunks: list, store_name: str, api: str):
store_name = store_name
if os.path.exists(f"{store_name}.pkl"):
with open(f"{store_name}.pkl", "rb") as f:
VectorStore = pickle.load(f)
# st.write("Embeddings loaded from the disk")
return VectorStore
else:
embeddings = OpenAIEmbeddings(openai_api_key=api)
VectorStore = FAISS.from_texts(chunks, embeddings)
with open(f"{store_name}.pkl", "wb") as f:
pickle.dump(VectorStore, f)
# st.write("Embeddings generated and saved to disk")
return VectorStoreEditor is loading...