Spaces:
Sleeping
Sleeping
DeyPoulomi
commited on
Commit
•
a890f0d
1
Parent(s):
91ae1d6
Update utils.py
Browse files
utils.py
CHANGED
@@ -51,11 +51,11 @@ def create_embeddings_load_data():
|
|
51 |
|
52 |
|
53 |
#Function to push data to Vector Store - Pinecone here
|
54 |
-
def push_to_pinecone(
|
55 |
|
56 |
pinecone.init(
|
57 |
-
api_key=
|
58 |
-
environment=
|
59 |
)
|
60 |
|
61 |
Pinecone.from_documents(docs, embeddings, index_name=pinecone_index_name)
|
@@ -63,15 +63,15 @@ def push_to_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,em
|
|
63 |
|
64 |
|
65 |
#Function to pull infrmation from Vector Store - Pinecone here
|
66 |
-
def pull_from_pinecone(
|
67 |
# For some of the regions allocated in pinecone which are on free tier, the data takes upto 10secs for it to available for filtering
|
68 |
#so I have introduced 20secs here, if its working for you without this delay, you can remove it :)
|
69 |
#https://docs.pinecone.io/docs/starter-environment
|
70 |
print("20secs delay...")
|
71 |
time.sleep(20)
|
72 |
pinecone.init(
|
73 |
-
api_key=
|
74 |
-
environment=
|
75 |
)
|
76 |
|
77 |
index_name = pinecone_index_name
|
@@ -82,16 +82,16 @@ def pull_from_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,
|
|
82 |
|
83 |
|
84 |
#Function to help us get relavant documents from vector store - based on user input
|
85 |
-
def similar_docs(query,k,
|
86 |
|
87 |
pinecone.init(
|
88 |
-
api_key=
|
89 |
-
environment=
|
90 |
)
|
91 |
|
92 |
index_name = pinecone_index_name
|
93 |
|
94 |
-
index = pull_from_pinecone(
|
95 |
similar_docs = index.similarity_search_with_score(query, int(k),{"unique_id":unique_id})
|
96 |
#print(similar_docs)
|
97 |
return similar_docs
|
|
|
51 |
|
52 |
|
53 |
#Function to push data to Vector Store - Pinecone here
|
54 |
+
def push_to_pinecone(PINECONE_PROJECT_ID,PINECONE_REGION,pinecone_index_name,embeddings,docs):
|
55 |
|
56 |
pinecone.init(
|
57 |
+
api_key=PINECONE_PROJECT_ID,
|
58 |
+
environment=PINECONE_REGION
|
59 |
)
|
60 |
|
61 |
Pinecone.from_documents(docs, embeddings, index_name=pinecone_index_name)
|
|
|
63 |
|
64 |
|
65 |
#Function to pull infrmation from Vector Store - Pinecone here
|
66 |
+
def pull_from_pinecone(PINECONE_PROJECT_ID,PINECONE_REGION,pinecone_index_name,embeddings):
|
67 |
# For some of the regions allocated in pinecone which are on free tier, the data takes upto 10secs for it to available for filtering
|
68 |
#so I have introduced 20secs here, if its working for you without this delay, you can remove it :)
|
69 |
#https://docs.pinecone.io/docs/starter-environment
|
70 |
print("20secs delay...")
|
71 |
time.sleep(20)
|
72 |
pinecone.init(
|
73 |
+
api_key=PINECONE_PROJECT_ID,
|
74 |
+
environment=PINECONE_REGION
|
75 |
)
|
76 |
|
77 |
index_name = pinecone_index_name
|
|
|
82 |
|
83 |
|
84 |
#Function to help us get relavant documents from vector store - based on user input
|
85 |
+
def similar_docs(query,k,PINECONE_PROJECT_ID,PINECONE_REGION,pinecone_index_name,embeddings,unique_id):
|
86 |
|
87 |
pinecone.init(
|
88 |
+
api_key=PINECONE_PROJECT_ID,
|
89 |
+
environment=PINECONE_REGION
|
90 |
)
|
91 |
|
92 |
index_name = pinecone_index_name
|
93 |
|
94 |
+
index = pull_from_pinecone(PINECONE_PROJECT_ID,PINECONE_REGION,index_name,embeddings)
|
95 |
similar_docs = index.similarity_search_with_score(query, int(k),{"unique_id":unique_id})
|
96 |
#print(similar_docs)
|
97 |
return similar_docs
|