Ankoorkashyap commited on
Commit
59d3221
·
verified ·
1 Parent(s): f5282fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -6,7 +6,7 @@ from langchain_community.vectorstores import FAISS
6
  from langchain.memory import ConversationBufferMemory
7
  from langchain.chains import ConversationalRetrievalChain
8
  from htmlTemplates import css, bot_template, user_template
9
- from langchain_community.llms import HuggingFaceEndpoint
10
  import os
11
  from langchain_huggingface import HuggingFaceEmbeddings
12
 
@@ -41,11 +41,10 @@ def get_vectorstore(text_chunks):
41
  def get_conversation_chain(vectorstore):
42
  os.environ["HUGGINGFACEHUB_API_TOKEN"] = os.getenv("HUGGINGFACEHUB_API_TOKEN", "")
43
 
44
- llm = HuggingFaceEndpoint(
45
  repo_id="google/flan-t5-base",
46
  huggingfacehub_api_token=os.environ["HUGGINGFACEHUB_API_TOKEN"],
47
- temperature=0.5,
48
- max_length=512
49
  )
50
 
51
  memory = ConversationBufferMemory(
@@ -61,6 +60,7 @@ def get_conversation_chain(vectorstore):
61
  return conversation_chain
62
 
63
 
 
64
  def handle_userinput(user_question):
65
  if st.session_state.conversation is None:
66
  st.warning("Please upload PDFs and click 'Process' before asking questions.")
 
6
  from langchain.memory import ConversationBufferMemory
7
  from langchain.chains import ConversationalRetrievalChain
8
  from htmlTemplates import css, bot_template, user_template
9
+ from langchain_community.llms import HuggingFaceHub
10
  import os
11
  from langchain_huggingface import HuggingFaceEmbeddings
12
 
 
41
  def get_conversation_chain(vectorstore):
42
  os.environ["HUGGINGFACEHUB_API_TOKEN"] = os.getenv("HUGGINGFACEHUB_API_TOKEN", "")
43
 
44
+ llm = HuggingFaceHub(
45
  repo_id="google/flan-t5-base",
46
  huggingfacehub_api_token=os.environ["HUGGINGFACEHUB_API_TOKEN"],
47
+ model_kwargs={"temperature": 0.5, "max_length": 512}
 
48
  )
49
 
50
  memory = ConversationBufferMemory(
 
60
  return conversation_chain
61
 
62
 
63
+
64
  def handle_userinput(user_question):
65
  if st.session_state.conversation is None:
66
  st.warning("Please upload PDFs and click 'Process' before asking questions.")