PraneshJs commited on
Commit
d7e845d
·
verified ·
1 Parent(s): 0b436fd

Fixed issues added comments correctly

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -13,7 +13,7 @@ from dotenv import load_dotenv
13
 
14
  load_dotenv()
15
 
16
- === CONFIG ===
17
 
18
  STORAGE_DIR = "storage"
19
  CLEANUP_INTERVAL = 600 # 10 min
@@ -24,7 +24,7 @@ OPENROUTER_MODEL = "z-ai/glm-4.5-air:free"
24
  if not os.path.exists(STORAGE_DIR):
25
  os.makedirs(STORAGE_DIR)
26
 
27
- === CLEANUP THREAD ===
28
 
29
  def cleanup_old_sessions():
30
  while True:
@@ -37,7 +37,7 @@ time.sleep(CLEANUP_INTERVAL)
37
 
38
  Thread(target=cleanup_old_sessions, daemon=True).start()
39
 
40
- === PDF PROCESSING ===
41
 
42
  def process_pdf(pdf_file):
43
  if pdf_file is None:
@@ -59,7 +59,7 @@ db.save_local(session_path)
59
  chat_history = [("System", "Paper uploaded and processed. You can now ask questions.")]
60
  return f"Paper uploaded successfully. Session ID: {session_id}", session_id, chat_history
61
 
62
- === QUERY FUNCTION ===
63
 
64
  def query_paper(session_id, user_message, chat_history):
65
  if not session_id or not os.path.exists(os.path.join(STORAGE_DIR, session_id)):
@@ -115,7 +115,7 @@ chat_history.append((user_message, answer))
115
 
116
  return chat_history, ""
117
 
118
- === GRADIO UI ===
119
 
120
  with gr.Blocks() as demo:
121
  gr.Markdown("## 📄 Research Paper Chatbot (RAG + OpenRouter)")
 
13
 
14
  load_dotenv()
15
 
16
+ #=== CONFIG ===
17
 
18
  STORAGE_DIR = "storage"
19
  CLEANUP_INTERVAL = 600 # 10 min
 
24
  if not os.path.exists(STORAGE_DIR):
25
  os.makedirs(STORAGE_DIR)
26
 
27
+ #=== CLEANUP THREAD ===
28
 
29
  def cleanup_old_sessions():
30
  while True:
 
37
 
38
  Thread(target=cleanup_old_sessions, daemon=True).start()
39
 
40
+ #=== PDF PROCESSING ===
41
 
42
  def process_pdf(pdf_file):
43
  if pdf_file is None:
 
59
  chat_history = [("System", "Paper uploaded and processed. You can now ask questions.")]
60
  return f"Paper uploaded successfully. Session ID: {session_id}", session_id, chat_history
61
 
62
+ #=== QUERY FUNCTION ===
63
 
64
  def query_paper(session_id, user_message, chat_history):
65
  if not session_id or not os.path.exists(os.path.join(STORAGE_DIR, session_id)):
 
115
 
116
  return chat_history, ""
117
 
118
+ #=== GRADIO UI ===
119
 
120
  with gr.Blocks() as demo:
121
  gr.Markdown("## 📄 Research Paper Chatbot (RAG + OpenRouter)")