fehmikaya commited on
Commit
2e9fddc
·
verified ·
1 Parent(s): 893c688

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -32,11 +32,12 @@ remote_llm = CustomLlama3(bearer_token = HF_TOKEN)
32
  retriever = None
33
 
34
  def data_ingestion():
 
35
  docs=[]
36
-
37
- if os.path.exists(DATA_DIR+"/saved_link.txt"):
38
  try:
39
- with open(DATA_DIR+"/saved_link.txt", 'r') as file:
40
  url = file.read()
41
  web_doc = WebBaseLoader(url).load()
42
  if web_doc:
@@ -44,11 +45,14 @@ def data_ingestion():
44
  except Exception as e:
45
  print(e)
46
 
47
- if os.path.exists(DATA_DIR+"/saved_pdf.pdf"):
48
- pdf_loader = PyPDFLoader(DATA_DIR+"/saved_pdf.pdf")
49
- pdf_doc = pdf_loader.load()
50
- if pdf_doc:
51
- docs.append(pdf_doc)
 
 
 
52
 
53
  docs_list = [item for sublist in docs for item in sublist]
54
 
@@ -65,7 +69,6 @@ def data_ingestion():
65
  collection_name="rag-chroma",
66
  embedding=embedding_function,
67
  )
68
- global retriever
69
  retriever = vectorstore.as_retriever()
70
 
71
  def remove_old_files():
@@ -82,7 +85,7 @@ def retrieval_grader(question):
82
  Question: {question}
83
  Context: {context}
84
  Answer: <|eot_id|><|start_header_id|>assistant<|end_header_id|>""",
85
- input_variables=["question", "document"],
86
  )
87
 
88
  # Chain
 
32
  retriever = None
33
 
34
  def data_ingestion():
35
+ global retriever
36
  docs=[]
37
+
38
+ if os.path.exists(os.path.join(DATA_DIR, "saved_link.txt")):
39
  try:
40
+ with open(os.path.join(DATA_DIR, "saved_link.txt"), 'r') as file:
41
  url = file.read()
42
  web_doc = WebBaseLoader(url).load()
43
  if web_doc:
 
45
  except Exception as e:
46
  print(e)
47
 
48
+ if os.path.exists(os.path.join(DATA_DIR, "saved_pdf.pdf")):
49
+ try:
50
+ pdf_loader = PyPDFLoader(os.path.join(DATA_DIR, "saved_pdf.pdf"))
51
+ pdf_doc = pdf_loader.load()
52
+ if pdf_doc:
53
+ docs.append(pdf_doc)
54
+ except Exception as e:
55
+ print(e)
56
 
57
  docs_list = [item for sublist in docs for item in sublist]
58
 
 
69
  collection_name="rag-chroma",
70
  embedding=embedding_function,
71
  )
 
72
  retriever = vectorstore.as_retriever()
73
 
74
  def remove_old_files():
 
85
  Question: {question}
86
  Context: {context}
87
  Answer: <|eot_id|><|start_header_id|>assistant<|end_header_id|>""",
88
+ input_variables=["question", "context"],
89
  )
90
 
91
  # Chain