Spaces:
Runtime error
Runtime error
Commit
·
0290079
1
Parent(s):
58e9235
Update pinecone.py
Browse files- pinecone.py +7 -19
pinecone.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import uuid
|
2 |
import pinecone
|
3 |
-
from pinecone import PineconeProtocolError
|
4 |
class Pinecone:
|
5 |
def __init__(self, api_key, environment, index_name):
|
6 |
self.api_key = api_key
|
@@ -25,22 +24,11 @@ class Pinecone:
|
|
25 |
self.index.upsert(data)
|
26 |
|
27 |
def search_data(self, query_embedding):
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
except PineconeProtocolError as e:
|
36 |
-
print(f"PineconeProtocolError occurred: {e}")
|
37 |
-
pinecone.deinit()
|
38 |
-
pinecone.init(api_key= self.api_key,environment=self.environment)
|
39 |
-
index = pinecone.Index(self.index_name)
|
40 |
-
matches = index.query(
|
41 |
-
vector=query_embedding,
|
42 |
-
top_k=10,
|
43 |
-
include_values=True,
|
44 |
-
include_metadata = True
|
45 |
-
)
|
46 |
return matches
|
|
|
1 |
import uuid
|
2 |
import pinecone
|
|
|
3 |
class Pinecone:
|
4 |
def __init__(self, api_key, environment, index_name):
|
5 |
self.api_key = api_key
|
|
|
24 |
self.index.upsert(data)
|
25 |
|
26 |
def search_data(self, query_embedding):
|
27 |
+
|
28 |
+
matches = self.index.query(
|
29 |
+
vector=query_embedding,
|
30 |
+
top_k=10,
|
31 |
+
include_values=True,
|
32 |
+
include_metadata = True
|
33 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
return matches
|