Spaces:
Sleeping
Sleeping
fix for AttributeError
Browse filesif not state.is_db_ready(): AttributeError: 'NoneType' object has no attribute 'is_db_ready'
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 |
-
|
|
|
|
| 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 |
|