Spaces:
Sleeping
Sleeping
palitrajarshi
commited on
Commit
·
8a0c93a
1
Parent(s):
45eb819
Update utils.py
Browse files
utils.py
CHANGED
@@ -50,49 +50,6 @@ def create_embeddings_load_data():
|
|
50 |
return embeddings
|
51 |
|
52 |
|
53 |
-
#Function to push data to Vector Store - Pinecone here
|
54 |
-
def push_to_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings,docs):
|
55 |
-
|
56 |
-
pinecone.init(
|
57 |
-
api_key=pinecone_apikey,
|
58 |
-
environment=pinecone_environment
|
59 |
-
)
|
60 |
-
print("done......2")
|
61 |
-
Pinecone.from_documents(docs, embeddings, index_name=pinecone_index_name)
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
#Function to pull infrmation from Vector Store - Pinecone here
|
66 |
-
def pull_from_pinecone(pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings):
|
67 |
-
|
68 |
-
pinecone.init(
|
69 |
-
api_key=pinecone_apikey,
|
70 |
-
environment=pinecone_environment
|
71 |
-
)
|
72 |
-
|
73 |
-
index_name = pinecone_index_name
|
74 |
-
|
75 |
-
index = Pinecone.from_existing_index(index_name, embeddings)
|
76 |
-
return index
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
#Function to help us get relavant documents from vector store - based on user input
|
81 |
-
def similar_docs(query,k,pinecone_apikey,pinecone_environment,pinecone_index_name,embeddings,unique_id):
|
82 |
-
|
83 |
-
pinecone.init(
|
84 |
-
api_key=pinecone_apikey,
|
85 |
-
environment=pinecone_environment
|
86 |
-
)
|
87 |
-
|
88 |
-
index_name = pinecone_index_name
|
89 |
-
|
90 |
-
index = pull_from_pinecone(pinecone_apikey,pinecone_environment,index_name,embeddings)
|
91 |
-
#similar_docs = index.similarity_search_with_score(query, int(k),{"unique_id":unique_id})
|
92 |
-
similar_docs = index.similarity_search_with_score(query, int(k))
|
93 |
-
#print(similar_docs)
|
94 |
-
return similar_docs
|
95 |
-
|
96 |
def close_matches(query,k,docs,embeddings):
|
97 |
#https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.faiss.FAISS.html#langchain.vectorstores.faiss.FAISS.similarity_search_with_score
|
98 |
db = FAISS.from_documents(docs, embeddings)
|
|
|
50 |
return embeddings
|
51 |
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
def close_matches(query,k,docs,embeddings):
|
54 |
#https://api.python.langchain.com/en/latest/vectorstores/langchain.vectorstores.faiss.FAISS.html#langchain.vectorstores.faiss.FAISS.similarity_search_with_score
|
55 |
db = FAISS.from_documents(docs, embeddings)
|