AroojImtiaz
commited on
Commit
•
1568665
1
Parent(s):
aafc957
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ import io
|
|
12 |
|
13 |
# st.title("Chat Your PDFs") # Updated title
|
14 |
st.set_page_config(layout="centered")
|
15 |
-
st.markdown("<h1 style='font-size:24px;'>
|
16 |
|
17 |
# Load environment variables from .env file
|
18 |
load_dotenv()
|
@@ -26,7 +26,7 @@ if google_api_key is None:
|
|
26 |
st.stop()
|
27 |
|
28 |
# File Upload with user-defined name
|
29 |
-
uploaded_file = st.file_uploader("
|
30 |
|
31 |
prompt_template = """
|
32 |
Answer the question as detailed as possible from the provided context,
|
@@ -42,26 +42,26 @@ Answer:
|
|
42 |
prompt_template = prompt_template + """
|
43 |
--------------------------------------------------
|
44 |
Prompt Suggestions:
|
45 |
-
1. Summarize the
|
46 |
-
2.
|
47 |
-
3.
|
48 |
-
4.
|
49 |
-
5.
|
50 |
-
6.
|
51 |
-
7.
|
52 |
-
8.
|
53 |
-
9.
|
54 |
-
10.
|
55 |
-
11.
|
56 |
-
12.
|
57 |
-
13.
|
58 |
-
14.
|
59 |
-
15.
|
60 |
-
16.
|
61 |
-
17.
|
62 |
-
18.
|
63 |
-
19.
|
64 |
-
20.
|
65 |
"""
|
66 |
|
67 |
# Return the enhanced prompt template
|
@@ -73,7 +73,7 @@ Answer:
|
|
73 |
"""
|
74 |
|
75 |
if uploaded_file is not None:
|
76 |
-
st.text("
|
77 |
|
78 |
# PDF Processing (using PyPDF2 directly)
|
79 |
pdf_data = uploaded_file.read()
|
@@ -87,7 +87,7 @@ if uploaded_file is not None:
|
|
87 |
# vector_index = Chroma.from_texts(texts, embeddings).as_retriever()
|
88 |
vector_index = FAISS.from_texts(texts, embeddings).as_retriever()
|
89 |
|
90 |
-
user_question = st.text_input("
|
91 |
|
92 |
|
93 |
|
|
|
12 |
|
13 |
# st.title("Chat Your PDFs") # Updated title
|
14 |
st.set_page_config(layout="centered")
|
15 |
+
st.markdown("<h1 style='font-size:24px;'>PDF ChatBot by Arooj & Ali</h1>", unsafe_allow_html=True)
|
16 |
|
17 |
# Load environment variables from .env file
|
18 |
load_dotenv()
|
|
|
26 |
st.stop()
|
27 |
|
28 |
# File Upload with user-defined name
|
29 |
+
uploaded_file = st.file_uploader("Your PDF file here", type=["pdf"])
|
30 |
|
31 |
prompt_template = """
|
32 |
Answer the question as detailed as possible from the provided context,
|
|
|
42 |
prompt_template = prompt_template + """
|
43 |
--------------------------------------------------
|
44 |
Prompt Suggestions:
|
45 |
+
1. Summarize the primary theme of the context.
|
46 |
+
2. Elaborate on the crucial concepts highlighted in the context.
|
47 |
+
3. Pinpoint any supporting details or examples pertinent to the question.
|
48 |
+
4. Examine any recurring themes or patterns relevant to the question within the context.
|
49 |
+
5. Contrast differing viewpoints or elements mentioned in the context.
|
50 |
+
6. Explore the potential implications or outcomes of the information provided.
|
51 |
+
7. Assess the trustworthiness and validity of the information given.
|
52 |
+
8. Propose recommendations or advice based on the presented information.
|
53 |
+
9. Forecast likely future events or results stemming from the context.
|
54 |
+
10. Expand on the context or background information pertinent to the question.
|
55 |
+
11. Define any specialized terms or technical language used within the context.
|
56 |
+
12. Analyze any visual representations like charts or graphs in the context.
|
57 |
+
13. Highlight any restrictions or important considerations when responding to the question.
|
58 |
+
14. Examine any presuppositions or biases evident within the context.
|
59 |
+
15. Present alternate interpretations or viewpoints regarding the information provided.
|
60 |
+
16. Reflect on any moral or ethical issues raised by the context.
|
61 |
+
17. Investigate any cause-and-effect relationships identified in the context.
|
62 |
+
18. Uncover any questions or areas requiring further exploration.
|
63 |
+
19. Resolve any vague or conflicting information in the context.
|
64 |
+
20. Cite case studies or examples that demonstrate the concepts discussed in the context.
|
65 |
"""
|
66 |
|
67 |
# Return the enhanced prompt template
|
|
|
73 |
"""
|
74 |
|
75 |
if uploaded_file is not None:
|
76 |
+
st.text("File Uploaded Successfully!")
|
77 |
|
78 |
# PDF Processing (using PyPDF2 directly)
|
79 |
pdf_data = uploaded_file.read()
|
|
|
87 |
# vector_index = Chroma.from_texts(texts, embeddings).as_retriever()
|
88 |
vector_index = FAISS.from_texts(texts, embeddings).as_retriever()
|
89 |
|
90 |
+
user_question = st.text_input("Ask Anything from PDF:", "")
|
91 |
|
92 |
|
93 |
|