saaketvarma commited on
Commit
5f38a82
·
1 Parent(s): 19becf1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -43,9 +43,23 @@ def data_ingestion():
43
  splits = text_splitter.split_documents(documents)
44
 
45
  # create embeddings here
46
- embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
47
- vectordb = FAISS.from_documents(splits, embeddings)
48
- vectordb.save_local("faiss_index")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
 
51
  @st.cache_resource
 
43
  splits = text_splitter.split_documents(documents)
44
 
45
  # create embeddings here
46
+ #embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
47
+ openai.api_key = os.getenv("OPENAI_API_KEY")
48
+ model = "text-embedding-ada-002"
49
+
50
+ embeddings = []
51
+ for split in splits:
52
+ completion = openai.Completion.create(
53
+ model=model,
54
+ prompt=split,
55
+ temperature=0.7,
56
+ max_tokens=100,
57
+ )
58
+
59
+ embedding = completion.choices[0].embedding
60
+ embeddings.append(embedding)
61
+ vectordb = FAISS.from_documents(splits, embeddings)
62
+ vectordb.save_local("faiss_index")
63
 
64
 
65
  @st.cache_resource