Kushwanth Chowday Kandala commited on
Commit
c9dd21c
1 Parent(s): dcca063

ImportError: cannot import name 'GRPCIndex' from 'pinecone'

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -42,11 +42,13 @@ PINECONE_API_KEY=os.getenv("PINECONE_API_KEY")
42
  PINECONE_ENV=os.getenv("PINECONE_ENV")
43
  PINECONE_ENVIRONMENT=os.getenv("PINECONE_ENVIRONMENT")
44
 
 
 
45
  def connect_pinecone():
46
- pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENV)
47
  st.code(pinecone)
48
  st.divider()
49
- st.text(pinecone.list_indexes())
50
  st.divider()
51
  st.text(f"Succesfully connected to the pinecone")
52
  return pinecone
@@ -55,12 +57,13 @@ def get_pinecone_semantic_index(pinecone):
55
  index_name = "sematic-search"
56
 
57
  # only create if it deosnot exists
58
- if index_name not in pinecone.list_indexes():
59
  pinecone.create_index(
60
  name=index_name,
61
  description="Semantic search",
62
  dimension=model.get_sentence_embedding_dimension(),
63
  metric="cosine",
 
64
  )
65
  # now connect to index
66
  index = PineconeGRPC(index_name)
 
42
  PINECONE_ENV=os.getenv("PINECONE_ENV")
43
  PINECONE_ENVIRONMENT=os.getenv("PINECONE_ENVIRONMENT")
44
 
45
+ pc = Pinecone( api_key=os.environ.get("PINECONE_API_KEY") ) # Now do stuff if 'my_index' not in pc.list_indexes().names(): pc.create_index( name='my_index', dimension=1536, metric='euclidean', spec=ServerlessSpec( cloud='aws', region='us-west-2' ) )
46
+
47
  def connect_pinecone():
48
+ pinecone = Pinecone(api_key=PINECONE_API_KEY, environment=PINECONE_ENV)
49
  st.code(pinecone)
50
  st.divider()
51
+ st.text(pinecone.list_indexes().names())
52
  st.divider()
53
  st.text(f"Succesfully connected to the pinecone")
54
  return pinecone
 
57
  index_name = "sematic-search"
58
 
59
  # only create if it deosnot exists
60
+ if index_name not in pinecone.list_indexes().names():
61
  pinecone.create_index(
62
  name=index_name,
63
  description="Semantic search",
64
  dimension=model.get_sentence_embedding_dimension(),
65
  metric="cosine",
66
+ spec=ServerlessSpec( cloud='gcp', region='us-central1' )
67
  )
68
  # now connect to index
69
  index = PineconeGRPC(index_name)