AroojImtiaz commited on
Commit
1568665
1 Parent(s): aafc957

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -24
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;'>RAG with LangChain & GenAI: Any PDF</h1>", unsafe_allow_html=True)
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("Upload a PDF file", type=["pdf"])
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 main idea of the context.
46
- 2. Provide a detailed explanation of the key concepts mentioned in the context.
47
- 3. Identify any supporting evidence or examples that can be used to answer the question.
48
- 4. Analyze any trends or patterns mentioned in the context that are relevant to the question.
49
- 5. Compare and contrast different aspects or viewpoints presented in the context.
50
- 6. Discuss any implications or consequences of the information provided in the context.
51
- 7. Evaluate the reliability or credibility of the information presented in the context.
52
- 8. Offer recommendations or suggestions based on the information provided.
53
- 9. Predict potential future developments or outcomes based on the context.
54
- 10. Provide additional context or background information relevant to the question.
55
- 11. Explain any technical terms or jargon used in the context.
56
- 12. Interpret any charts, graphs, or visual aids included in the context.
57
- 13. Discuss any limitations or caveats that should be considered when answering the question.
58
- 14. Address any potential biases or assumptions present in the context.
59
- 15. Offer alternative perspectives or interpretations of the information provided.
60
- 16. Discuss any ethical considerations or implications raised by the context.
61
- 17. Analyze any cause-and-effect relationships mentioned in the context.
62
- 18. Identify any unanswered questions or areas for further investigation.
63
- 19. Clarify any ambiguities or inconsistencies in the context.
64
- 20. Provide examples or case studies that illustrate the concepts discussed in the context.
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("PDF File Uploaded Successfully!")
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("Enter your Question below:", "")
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