abaliyan commited on
Commit
cb56324
·
verified ·
1 Parent(s): 05dd597

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +7 -3
utils.py CHANGED
@@ -50,7 +50,11 @@ def push_to_pinecone(docs, embedding,namespace):
50
  index_name=os.environ.get("PINECONE_INDEX_NAME")
51
  index = pc.Index(index_name)
52
 
53
- # index.delete(delete_all=True, namespace='rag_bot')
 
 
 
 
54
 
55
  vector = []
56
  for i, doc in enumerate(docs):
@@ -60,7 +64,7 @@ def push_to_pinecone(docs, embedding,namespace):
60
  vector.append(entry)
61
 
62
 
63
- index = Pinecone.from_documents(docs, embedding, index_name = index_name, namespace=namespace)
64
 
65
  st.sidebar.write("This 35 seconds delay was added Manually... \n(because I'm using some free resources)")
66
  time.sleep(35)
@@ -80,7 +84,7 @@ def pull_from_pinecone(embeddings):
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
 
 
50
  index_name=os.environ.get("PINECONE_INDEX_NAME")
51
  index = pc.Index(index_name)
52
 
53
+ namespace_list = list(index_dict["namespaces"].keys())
54
+ if "rag_bot" in namespace_list:
55
+ index.delete(delete_all=True, namespace='rag_bot')
56
+ else:
57
+ pass
58
 
59
  vector = []
60
  for i, doc in enumerate(docs):
 
64
  vector.append(entry)
65
 
66
 
67
+ index = Pinecone.from_documents(docs, embedding, index_name = index_name, namespace='rag_bot')
68
 
69
  st.sidebar.write("This 35 seconds delay was added Manually... \n(because I'm using some free resources)")
70
  time.sleep(35)
 
84
  )
85
 
86
  #PineconeStore is an alias name of Pinecone class, please look at the imports section at the top :)
87
+ index = Pinecone.from_existing_index(pinecone_index_name, embeddings, namespace='rag_bot')
88
 
89
  return index
90