KushwanthK commited on
Commit
bb8243d
·
verified ·
1 Parent(s): 648030c

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -234,17 +234,18 @@ print(faiss_index)
234
  # def promt_engineer(text):
235
  PROMPT_TEMPLATE = """
236
  Instructions:
237
- -----------------------------------------------------------------------------------------
238
- Answer the question only based on the below context:
239
  - You're a Vedic AI expert in the Hindu Vedic scriptures.
 
240
  - Always try to provide Keep it simple answers in nice format without incomplete sentence.
241
  - Give the answer atleast 5 seperate lines addition to the title info.
242
  - provide Title: <title> Chapter: <chapter> Text No: <textnumber> Page No: <pagenumber>
243
- ------------------------------------------------------------------------------------------
244
 
245
  {context}
246
 
247
- ----------------------------------------------------------------------------------
248
 
249
  Answer the question based on the above context: {question}
250
  """
@@ -314,7 +315,11 @@ def chat_actions():
314
  # Example usage
315
  file_path = "Bhagavad-Gita-As-It-Is.pdf"
316
  text_to_highlight = context_text.strip()
317
- display_highlighted_pdf(file_path, result, sources)
 
 
 
 
318
 
319
  with st.sidebar:
320
  option = st.selectbox(
 
234
  # def promt_engineer(text):
235
  PROMPT_TEMPLATE = """
236
  Instructions:
237
+ -------------------------------------------------------------------------------------------------------
238
+ Answer the question only based on the below context:
239
  - You're a Vedic AI expert in the Hindu Vedic scriptures.
240
+ - Questions with out-of-context replay with The question is out of context.
241
  - Always try to provide Keep it simple answers in nice format without incomplete sentence.
242
  - Give the answer atleast 5 seperate lines addition to the title info.
243
  - provide Title: <title> Chapter: <chapter> Text No: <textnumber> Page No: <pagenumber>
244
+ --------------------------------------------------------------------------------------------------------
245
 
246
  {context}
247
 
248
+ --------------------------------------------------------------------------------------------------------
249
 
250
  Answer the question based on the above context: {question}
251
  """
 
315
  # Example usage
316
  file_path = "Bhagavad-Gita-As-It-Is.pdf"
317
  text_to_highlight = context_text.strip()
318
+
319
+ if "The question is out of context" not in result:
320
+ display_highlighted_pdf(file_path, result, sources)
321
+ else:
322
+ st.error("The question is out of context. Pages not found.")
323
 
324
  with st.sidebar:
325
  option = st.selectbox(