nirmalaag commited on
Commit
f2e9fda
·
verified ·
1 Parent(s): 6d4ad7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -6,8 +6,8 @@ from PyPDF2 import PdfReader
6
  from langchain.text_splitter import RecursiveCharacterTextSplitter
7
  from langchain_community.embeddings.huggingface import HuggingFaceEmbeddings
8
  from langchain.vectorstores import chroma
9
- from langchain.chains.retrieval_qa.base import RetrievalQA
10
- #from langchain.chains.question_answering import load_qa_chain
11
  from langchain_community.llms import huggingface_hub
12
  from langchain.document_loaders.pdf import PyMuPDFLoader
13
  #from transformers import AutoTokenizer, AutoModelForCausalLM
@@ -68,12 +68,12 @@ def main():
68
  llm = huggingface_hub.HuggingFaceHub(repo_id="google/flan-t5-small",
69
  model_kwargs={"temperature":1.0, "max_length":256})
70
  docs = vector_store.similarity_search(query=query, k=3)
71
- global chain
72
- #chain = load_qa_chain(llm=llm, chain_type="stuff")
73
- #response = chain.run(input_documents=docs, question=query)
74
- retriever=vector_store.as_retriever()
75
- chain = RetrievalQA.from_chain_type(llm=llm,chain_type="stuff",retriever=retriever)
76
- response = chain.run(chain)
77
  st.write(response)
78
 
79
 
 
6
  from langchain.text_splitter import RecursiveCharacterTextSplitter
7
  from langchain_community.embeddings.huggingface import HuggingFaceEmbeddings
8
  from langchain.vectorstores import chroma
9
+ #from langchain.chains.retrieval_qa.base import RetrievalQA
10
+ from langchain.chains.question_answering import load_qa_chain
11
  from langchain_community.llms import huggingface_hub
12
  from langchain.document_loaders.pdf import PyMuPDFLoader
13
  #from transformers import AutoTokenizer, AutoModelForCausalLM
 
68
  llm = huggingface_hub.HuggingFaceHub(repo_id="google/flan-t5-small",
69
  model_kwargs={"temperature":1.0, "max_length":256})
70
  docs = vector_store.similarity_search(query=query, k=3)
71
+
72
+ chain = load_qa_chain(llm=llm, chain_type="stuff")
73
+ response = chain.run(input_documents=docs, question=query)
74
+ #retriever=vector_store.as_retriever()
75
+ #chain = RetrievalQA.from_chain_type(llm=llm,chain_type="stuff",retriever=retriever)
76
+ #response = chain.run(chain)
77
  st.write(response)
78
 
79