Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from langchain.memory import ConversationBufferMemory
|
|
| 9 |
from langchain.chains import ConversationalRetrievalChain
|
| 10 |
from htmlTemplates import css, bot_template, user_template
|
| 11 |
from langchain.llms import HuggingFaceHub
|
| 12 |
-
|
| 13 |
|
| 14 |
def get_pdf_text(pdf_docs):
|
| 15 |
text = ""
|
|
@@ -41,10 +41,11 @@ def get_vectorstore(text_chunks):
|
|
| 41 |
|
| 42 |
|
| 43 |
def get_conversation_chain(vectorstore):
|
| 44 |
-
llm =
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
| 48 |
|
| 49 |
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
|
| 50 |
conversation_chain = ConversationalRetrievalChain.from_llm(
|
|
@@ -73,10 +74,11 @@ def main():
|
|
| 73 |
st.markdown("# Chat💬 with multiple PDFs 📄")
|
| 74 |
|
| 75 |
st.write(css, unsafe_allow_html=True)
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
| 80 |
|
| 81 |
|
| 82 |
if "conversation" not in st.session_state:
|
|
|
|
| 9 |
from langchain.chains import ConversationalRetrievalChain
|
| 10 |
from htmlTemplates import css, bot_template, user_template
|
| 11 |
from langchain.llms import HuggingFaceHub
|
| 12 |
+
from langchain.llms import OpenAI
|
| 13 |
|
| 14 |
def get_pdf_text(pdf_docs):
|
| 15 |
text = ""
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
def get_conversation_chain(vectorstore):
|
| 44 |
+
llm = OpenAI(temperature=0.7, openai_api_key=openai_api_key)
|
| 45 |
+
# llm = HuggingFaceHub(
|
| 46 |
+
# repo_id="mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 47 |
+
# model_kwargs={"temperature": 0.5, "max_length": 1048},
|
| 48 |
+
# )
|
| 49 |
|
| 50 |
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
|
| 51 |
conversation_chain = ConversationalRetrievalChain.from_llm(
|
|
|
|
| 74 |
st.markdown("# Chat💬 with multiple PDFs 📄")
|
| 75 |
|
| 76 |
st.write(css, unsafe_allow_html=True)
|
| 77 |
+
|
| 78 |
+
openai_api_key = st.sidebar.text_input('OpenAI API Key',type="password")
|
| 79 |
+
os.environ["OpenAI_Key"] = huggingface_token
|
| 80 |
+
#huggingface_token = st.text_input("Enter your HuggingFace Hub token", type="password")
|
| 81 |
+
#os.environ["HUGGINGFACEHUB_API_TOKEN"] = huggingface_token
|
| 82 |
|
| 83 |
|
| 84 |
if "conversation" not in st.session_state:
|