Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,11 +43,10 @@ def get_conversational_chain():
|
|
| 43 |
provided context just say, "answer is not available in the context", don't provide the wrong answer\n\n
|
| 44 |
Context:\n {context}?\n
|
| 45 |
Question: \n{question}\n
|
| 46 |
-
|
| 47 |
Answer:
|
| 48 |
"""
|
| 49 |
|
| 50 |
-
model = ChatGroq(temperature=0, groq_api_key="
|
| 51 |
|
| 52 |
prompt = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
|
| 53 |
chain = load_qa_chain(model, chain_type="stuff", prompt=prompt)
|
|
@@ -80,25 +79,34 @@ def user_input(user_question, api_key):
|
|
| 80 |
text_to_speech(text)
|
| 81 |
|
| 82 |
def main():
|
| 83 |
-
|
| 84 |
-
st.
|
| 85 |
-
|
|
|
|
| 86 |
api_key = st.secrets["inference_api_key"]
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
if user_question:
|
| 91 |
-
user_input(user_question, api_key)
|
| 92 |
-
|
| 93 |
with st.sidebar:
|
| 94 |
-
st.
|
| 95 |
-
|
| 96 |
-
|
|
|
|
| 97 |
with st.spinner("Processing..."):
|
| 98 |
raw_text = get_pdf_text(pdf_docs)
|
| 99 |
text_chunks = get_text_chunks(raw_text)
|
| 100 |
get_vector_store(text_chunks, api_key)
|
| 101 |
st.success("Done")
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
if __name__ == "__main__":
|
| 104 |
main()
|
|
|
|
| 43 |
provided context just say, "answer is not available in the context", don't provide the wrong answer\n\n
|
| 44 |
Context:\n {context}?\n
|
| 45 |
Question: \n{question}\n
|
|
|
|
| 46 |
Answer:
|
| 47 |
"""
|
| 48 |
|
| 49 |
+
model = ChatGroq(temperature=0, groq_api_key=os.environ["groq_api_key"], model_name="llama3-8b-8192")
|
| 50 |
|
| 51 |
prompt = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
|
| 52 |
chain = load_qa_chain(model, chain_type="stuff", prompt=prompt)
|
|
|
|
| 79 |
text_to_speech(text)
|
| 80 |
|
| 81 |
def main():
|
| 82 |
+
|
| 83 |
+
st.set_page_config(layout="centered")
|
| 84 |
+
st.header("Chat with DOCS")
|
| 85 |
+
st.markdown("<h1 style='font-size:20px;'>ChatBot by Muhammad Huzaifa</h1>", unsafe_allow_html=True)
|
| 86 |
api_key = st.secrets["inference_api_key"]
|
| 87 |
+
|
| 88 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
with st.sidebar:
|
| 90 |
+
st.header("Chat with PDF")
|
| 91 |
+
# st.title("Menu:")
|
| 92 |
+
pdf_docs = st.file_uploader("Upload your PDF Files and Click on the Submit Button", accept_multiple_files=True, type=["pdf"])
|
| 93 |
+
if st.button("Submit"):
|
| 94 |
with st.spinner("Processing..."):
|
| 95 |
raw_text = get_pdf_text(pdf_docs)
|
| 96 |
text_chunks = get_text_chunks(raw_text)
|
| 97 |
get_vector_store(text_chunks, api_key)
|
| 98 |
st.success("Done")
|
| 99 |
+
|
| 100 |
+
if st.button("Summerize Chat"):
|
| 101 |
+
st.switch_page('pages/summarizer.py')
|
| 102 |
+
|
| 103 |
+
# Check if any document is uploaded
|
| 104 |
+
if pdf_docs:
|
| 105 |
+
user_question = st.text_input("Ask a question from the Docs")
|
| 106 |
+
if user_question:
|
| 107 |
+
user_input(user_question, api_key)
|
| 108 |
+
else:
|
| 109 |
+
st.write("Please upload a document first to ask questions.")
|
| 110 |
+
|
| 111 |
if __name__ == "__main__":
|
| 112 |
main()
|