nikhmr1235 commited on
Commit
656e456
·
verified ·
1 Parent(s): e2cd7fd

fix for AttributeError

Browse files

if not state.is_db_ready(): AttributeError: 'NoneType' object has no attribute 'is_db_ready'

Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -42,7 +42,7 @@ def new_session():
42
  def process_pdf(pdf_file, state):
43
  try:
44
  # Check if a PDF has already been processed in this session
45
- if state.is_db_ready():
46
  return (
47
  gr.update(interactive=False),
48
  gr.update(visible=True),
@@ -95,7 +95,8 @@ def process_pdf(pdf_file, state):
95
 
96
  # Function to handle user queries
97
  def chat_with_pdf(message, history, state):
98
- if not state.is_db_ready():
 
99
  yield "Please upload a PDF first to begin the conversation."
100
  return
101
 
 
42
  def process_pdf(pdf_file, state):
43
  try:
44
  # Check if a PDF has already been processed in this session
45
+ if state and state.is_db_ready():
46
  return (
47
  gr.update(interactive=False),
48
  gr.update(visible=True),
 
95
 
96
  # Function to handle user queries
97
  def chat_with_pdf(message, history, state):
98
+ # Add a defensive check for the state object itself
99
+ if not state or not state.is_db_ready():
100
  yield "Please upload a PDF first to begin the conversation."
101
  return
102