tahirsher commited on
Commit
fb8833d
Β·
verified Β·
1 Parent(s): c043266

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
app.py CHANGED
@@ -9,10 +9,10 @@ from langchain.vectorstores import FAISS
9
  from transformers import pipeline
10
  import torch
11
 
12
- # Set up the page configuration as the first Streamlit command
13
  st.set_page_config(page_title="RAG-based PDF Chat", layout="centered", page_icon="πŸ“„")
14
 
15
- # Load the summarization pipeline model
16
  @st.cache_resource
17
  def load_summarization_pipeline():
18
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
@@ -23,30 +23,28 @@ summarizer = load_summarization_pipeline()
23
  # Dictionary of Hugging Face PDF URLs grouped by folders
24
  PDF_FOLDERS = {
25
  "PPC and Administration": [
26
- "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/PPC%20and%20Administration",
27
  ],
28
  "IHC": [
29
  "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/IHC"
30
- ]
31
  "LHC": [
32
  "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/LHC"
33
- ]
34
  "Lahore High Court Rules and Orders": [
35
  "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/Lahore%20High%20Court%20Rules%20and%20Orders"
36
- ]
37
  "PHC": [
38
  "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/PHC"
39
- ]
40
  "SC": [
41
  "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/SC"
42
- ],
43
  }
44
 
45
  # Helper function to convert Hugging Face blob URLs to direct download URLs
46
  def get_huggingface_raw_url(url):
47
- if "huggingface.co" in url and "/blob/" in url:
48
- return url.replace("/blob/", "/resolve/")
49
- return url
50
 
51
  # Fetch and extract text from all PDFs in specified folders
52
  def fetch_pdf_text_from_folders(pdf_folders):
@@ -119,4 +117,4 @@ def main():
119
  st.markdown(f"**πŸ€– AI:** {answer}")
120
 
121
  if __name__ == "__main__":
122
- main()
 
9
  from transformers import pipeline
10
  import torch
11
 
12
+ # Set up the page configuration
13
  st.set_page_config(page_title="RAG-based PDF Chat", layout="centered", page_icon="πŸ“„")
14
 
15
+ # Load the summarization pipeline
16
  @st.cache_resource
17
  def load_summarization_pipeline():
18
  summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
 
23
  # Dictionary of Hugging Face PDF URLs grouped by folders
24
  PDF_FOLDERS = {
25
  "PPC and Administration": [
26
+ "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/PPC%20and%20Administration"
27
  ],
28
  "IHC": [
29
  "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/IHC"
30
+ ],
31
  "LHC": [
32
  "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/LHC"
33
+ ],
34
  "Lahore High Court Rules and Orders": [
35
  "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/Lahore%20High%20Court%20Rules%20and%20Orders"
36
+ ],
37
  "PHC": [
38
  "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/PHC"
39
+ ],
40
  "SC": [
41
  "https://huggingface.co/spaces/tahirsher/GenAI_Lawyers_Guide/tree/main/SC"
42
+ ]
43
  }
44
 
45
  # Helper function to convert Hugging Face blob URLs to direct download URLs
46
  def get_huggingface_raw_url(url):
47
+ return url.replace("/blob/", "/resolve/") if "huggingface.co" in url and "/blob/" in url else url
 
 
48
 
49
  # Fetch and extract text from all PDFs in specified folders
50
  def fetch_pdf_text_from_folders(pdf_folders):
 
117
  st.markdown(f"**πŸ€– AI:** {answer}")
118
 
119
  if __name__ == "__main__":
120
+ main()