ishaan-mital commited on
Commit
077ae05
·
1 Parent(s): 64fe6cc

initial commit

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -6,6 +6,7 @@ import pinecone
6
  from langchain.vectorstores import Pinecone
7
  import os
8
  from langchain.embeddings.huggingface import HuggingFaceEmbeddings
 
9
 
10
  API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
11
  # retrieval = Client("https://ishaan-mital-ncert-helper-vector-db.hf.space/--replicas/149bg26k5/")
@@ -28,7 +29,21 @@ pinecone.init(
28
  index_name = 'llama-rag'
29
  index = pinecone.Index(index_name)
30
  text_field = 'text' # field in metadata that contains text content
31
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  vectorstore = Pinecone(
33
  index, embed_model.embed_query, text_field
34
  )
 
6
  from langchain.vectorstores import Pinecone
7
  import os
8
  from langchain.embeddings.huggingface import HuggingFaceEmbeddings
9
+ import time
10
 
11
  API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
12
  # retrieval = Client("https://ishaan-mital-ncert-helper-vector-db.hf.space/--replicas/149bg26k5/")
 
29
  index_name = 'llama-rag'
30
  index = pinecone.Index(index_name)
31
  text_field = 'text' # field in metadata that contains text content
32
+ docs = [
33
+ "this is one document",
34
+ "and another document"
35
+ ]
36
+
37
+ embeddings = embed_model.embed_documents(docs)
38
+ if index_name not in pinecone.list_indexes():
39
+ pinecone.create_index(
40
+ index_name,
41
+ dimension=len(embeddings[0]),
42
+ metric='cosine'
43
+ )
44
+ # wait for index to finish initialization
45
+ while not pinecone.describe_index(index_name).status['ready']:
46
+ time.sleep(1)
47
  vectorstore = Pinecone(
48
  index, embed_model.embed_query, text_field
49
  )