File size: 752 Bytes
9a73c5d
8dae98c
 
af61c79
 
9a73c5d
af61c79
 
9a73c5d
8dae98c
af61c79
c75e17a
8dae98c
c75e17a
 
 
8dae98c
 
 
af61c79
8dae98c
c75e17a
af61c79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""This module is responsible for initializing the database connection and creating the necessary tables."""
from pinecone import Pinecone, ServerlessSpec
from langchain_pinecone import PineconeVectorStore
# from torch import embedding
from models.llm import GPTEmbeddings

# embeddings = EmbeddingsModel("all-MiniLM-L6-v2")
embeddings = GPTEmbeddings()

pc = Pinecone()
INDEX_NAME = "gmails"
if not pc.has_index(INDEX_NAME):
    pc.create_index(
        name=INDEX_NAME,
        dimension=len(embeddings.embed_query("hello")),
        metric="cosine",
        spec=ServerlessSpec(
            cloud="aws",
            region="us-east-1"
        )
    )
index = pc.Index(INDEX_NAME)
vectorstore = PineconeVectorStore(index=index, embedding=embeddings)