Aabbhishekk commited on
Commit
2092f50
1 Parent(s): ff6fd42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -7,7 +7,7 @@ from langchain.vectorstores import FAISS
7
  from langchain.chains.question_answering import load_qa_chain
8
  from langchain.callbacks import get_openai_callback
9
  from langchain import HuggingFaceHub, LLMChain
10
- from langchain.embeddings import HuggingFaceHubEmbeddings
11
  token = os.environ['HF_TOKEN']
12
  repo_id = "sentence-transformers/all-mpnet-base-v2"
13
  hf = HuggingFaceHubEmbeddings(
@@ -16,7 +16,11 @@ hf = HuggingFaceHubEmbeddings(
16
  huggingfacehub_api_token= token,
17
  )
18
 
 
19
 
 
 
 
20
 
21
 
22
  def main():
@@ -47,7 +51,7 @@ def main():
47
  # embeddings = OpenAIEmbeddings()
48
  # embeddings = query(chunks)
49
  # embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
50
- embeddings = hf
51
  knowledge_base = FAISS.from_texts(chunks, embeddings)
52
 
53
  # show user input
 
7
  from langchain.chains.question_answering import load_qa_chain
8
  from langchain.callbacks import get_openai_callback
9
  from langchain import HuggingFaceHub, LLMChain
10
+ from langchain.embeddings import HuggingFaceHubEmbeddings,HuggingFaceInferenceAPIEmbeddings
11
  token = os.environ['HF_TOKEN']
12
  repo_id = "sentence-transformers/all-mpnet-base-v2"
13
  hf = HuggingFaceHubEmbeddings(
 
16
  huggingfacehub_api_token= token,
17
  )
18
 
19
+ from langchain.embeddings import HuggingFaceInferenceAPIEmbeddings
20
 
21
+ embeddings = HuggingFaceInferenceAPIEmbeddings(
22
+ api_key=token, model_name="sentence-transformers/all-MiniLM-l6-v2"
23
+ )
24
 
25
 
26
  def main():
 
51
  # embeddings = OpenAIEmbeddings()
52
  # embeddings = query(chunks)
53
  # embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
54
+
55
  knowledge_base = FAISS.from_texts(chunks, embeddings)
56
 
57
  # show user input