-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathstore_index.py
More file actions
28 lines (19 loc) · 780 Bytes
/
store_index.py
File metadata and controls
28 lines (19 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from src.helper import load_pdf, text_split, download_hugging_face_embeddings
from langchain.vectorstores import Pinecone
import pinecone
from dotenv import load_dotenv
import os
load_dotenv()
PINECONE_API_KEY = os.environ.get('PINECONE_API_KEY')
PINECONE_API_ENV = os.environ.get('PINECONE_API_ENV')
# print(PINECONE_API_KEY)
# print(PINECONE_API_ENV)
extracted_data = load_pdf("data/")
text_chunks = text_split(extracted_data)
embeddings = download_hugging_face_embeddings()
#Initializing the Pinecone
pinecone.init(api_key=PINECONE_API_KEY,
environment=PINECONE_API_ENV)
index_name="medchat"
#Creating Embeddings for Each of The Text Chunks & storing
docsearch=Pinecone.from_texts([t.page_content for t in text_chunks], embeddings, index_name=index_name)