Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -70,7 +70,7 @@ def push_to_pinecone(docs, embedding,namespace):
|
|
| 70 |
|
| 71 |
|
| 72 |
#Function to pull index data from Pinecone
|
| 73 |
-
def pull_from_pinecone(embeddings
|
| 74 |
|
| 75 |
pinecone_apikey = os.environ.get("PINECONE_API_KEY")
|
| 76 |
pinecone_index_name =os.environ.get("PINECONE_INDEX_NAME")
|
|
@@ -80,20 +80,20 @@ def pull_from_pinecone(embeddings, namespace):
|
|
| 80 |
)
|
| 81 |
|
| 82 |
#PineconeStore is an alias name of Pinecone class, please look at the imports section at the top :)
|
| 83 |
-
index = Pinecone.from_existing_index(pinecone_index_name, embeddings, namespace=
|
| 84 |
|
| 85 |
return index
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
-
def get_similar_doc(query, embedding,k=2):
|
| 91 |
|
| 92 |
pc = PineconeClient(api_key=os.environ.get("PINECONE_API_KEY"))
|
| 93 |
index_name=os.environ.get("PINECONE_INDEX_NAME")
|
| 94 |
index = pc.Index(index_name)
|
| 95 |
|
| 96 |
-
index = pull_from_pinecone(embeddings=embedding
|
| 97 |
similar_doc = index.similarity_search_with_score(query, int(k))
|
| 98 |
|
| 99 |
return [doc for doc, similarity_score in similar_doc]
|
|
|
|
| 70 |
|
| 71 |
|
| 72 |
#Function to pull index data from Pinecone
|
| 73 |
+
def pull_from_pinecone(embeddings):
|
| 74 |
|
| 75 |
pinecone_apikey = os.environ.get("PINECONE_API_KEY")
|
| 76 |
pinecone_index_name =os.environ.get("PINECONE_INDEX_NAME")
|
|
|
|
| 80 |
)
|
| 81 |
|
| 82 |
#PineconeStore is an alias name of Pinecone class, please look at the imports section at the top :)
|
| 83 |
+
index = Pinecone.from_existing_index(pinecone_index_name, embeddings, namespace=os.environ.get("NAMESPACE"))
|
| 84 |
|
| 85 |
return index
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
+
def get_similar_doc(query, embedding, k=2):
|
| 91 |
|
| 92 |
pc = PineconeClient(api_key=os.environ.get("PINECONE_API_KEY"))
|
| 93 |
index_name=os.environ.get("PINECONE_INDEX_NAME")
|
| 94 |
index = pc.Index(index_name)
|
| 95 |
|
| 96 |
+
index = pull_from_pinecone(embeddings=embedding)
|
| 97 |
similar_doc = index.similarity_search_with_score(query, int(k))
|
| 98 |
|
| 99 |
return [doc for doc, similarity_score in similar_doc]
|