Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 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 =
|
| 45 |
repo_id="google/flan-t5-base",
|
| 46 |
huggingfacehub_api_token=os.environ["HUGGINGFACEHUB_API_TOKEN"],
|
| 47 |
-
temperature
|
| 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.")
|