Spaces:
Paused
Paused
fix pinecone startup
Browse files- pineconeclient.py +3 -1
pineconeclient.py
CHANGED
|
@@ -20,7 +20,6 @@ def init_pinecone():
|
|
| 20 |
pinecone = Pinecone(api_key=PINECONE_KEY, environment=PINE_CONE_ENVIRONMENT)
|
| 21 |
return pinecone.Index("semsearch")
|
| 22 |
|
| 23 |
-
st.session_state.index = init_pinecone()
|
| 24 |
|
| 25 |
|
| 26 |
|
|
@@ -38,6 +37,9 @@ def index_query(xq, top_k, regions=[], countries=[], index_namespace=""):
|
|
| 38 |
else:
|
| 39 |
filters = {}
|
| 40 |
#st.write(filter)
|
|
|
|
|
|
|
|
|
|
| 41 |
xc = st.session_state.index.query(vector = xq, namespace=index_namespace, top_k=20, filter = filters, include_metadata=True, include_vectors = False)
|
| 42 |
#xc = st.session_state.index.query(xq, top_k=top_k, include_metadata=True, include_vectors = True)
|
| 43 |
return xc
|
|
|
|
| 20 |
pinecone = Pinecone(api_key=PINECONE_KEY, environment=PINE_CONE_ENVIRONMENT)
|
| 21 |
return pinecone.Index("semsearch")
|
| 22 |
|
|
|
|
| 23 |
|
| 24 |
|
| 25 |
|
|
|
|
| 37 |
else:
|
| 38 |
filters = {}
|
| 39 |
#st.write(filter)
|
| 40 |
+
if not 'index' in st.session_state:
|
| 41 |
+
st.session_state.index = init_pinecone()
|
| 42 |
+
|
| 43 |
xc = st.session_state.index.query(vector = xq, namespace=index_namespace, top_k=20, filter = filters, include_metadata=True, include_vectors = False)
|
| 44 |
#xc = st.session_state.index.query(xq, top_k=top_k, include_metadata=True, include_vectors = True)
|
| 45 |
return xc
|