-
Notifications
You must be signed in to change notification settings - Fork 0
/
store_index.py
35 lines (23 loc) · 858 Bytes
/
store_index.py
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
29
30
31
32
33
34
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)
#load the pdf
extracted_data=load_pdf("data/")
#apply text splitter
text_chunks=text_split(extracted_data)
#download the embeddings
embeddings=download_hugging_face_embeddings()
#Initializing the Pinecone
pinecone.init(api_key=PINECONE_API_KEY,
environment=PINECONE_API_ENV)
#give index name
index_name="medical--chatbot"
#creating embeddings for each of the text chunks and storing
docsearch=Pinecone.from_texts([t.page_content for t in text_chunks], embeddings,index_name=index_name)