Spaces:
Runtime error
Runtime error
Fix: Add error handling around Gradio Blocks creation
Browse files
app.py
CHANGED
|
@@ -666,14 +666,24 @@ def create_interface(initial_bot: RAGBot, use_inference_api: bool = False) -> gr
|
|
| 666 |
if initial_model_short is None:
|
| 667 |
initial_model_short = list(MODEL_MAP.keys())[0]
|
| 668 |
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 677 |
|
| 678 |
with gr.Row():
|
| 679 |
with gr.Column(scale=2):
|
|
@@ -836,7 +846,29 @@ def create_interface(initial_bot: RAGBot, use_inference_api: bool = False) -> gr
|
|
| 836 |
category_output
|
| 837 |
]
|
| 838 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 839 |
|
|
|
|
| 840 |
return demo
|
| 841 |
|
| 842 |
|
|
|
|
| 666 |
if initial_model_short is None:
|
| 667 |
initial_model_short = list(MODEL_MAP.keys())[0]
|
| 668 |
|
| 669 |
+
# Create the Gradio interface with error handling
|
| 670 |
+
try:
|
| 671 |
+
with gr.Blocks(title="CGT-LLM-Beta RAG Chatbot") as demo:
|
| 672 |
+
gr.Markdown("""
|
| 673 |
+
# 🧬 CGT-LLM-Beta: Genetic Counseling RAG Chatbot
|
| 674 |
+
|
| 675 |
+
Ask questions about genetic counseling, cascade genetic testing, hereditary cancer syndromes, and related topics.
|
| 676 |
+
|
| 677 |
+
The chatbot uses a Retrieval-Augmented Generation (RAG) system to provide evidence-based answers from medical literature.
|
| 678 |
+
""")
|
| 679 |
+
except Exception as blocks_error:
|
| 680 |
+
logger.error(f"Error creating Gradio Blocks: {blocks_error}", exc_info=True)
|
| 681 |
+
# Create a minimal fallback
|
| 682 |
+
with gr.Blocks(title="CGT-LLM-Beta RAG Chatbot") as demo:
|
| 683 |
+
gr.Markdown(f"# Error\n\nFailed to create interface: {blocks_error}")
|
| 684 |
+
return demo
|
| 685 |
+
|
| 686 |
+
try:
|
| 687 |
|
| 688 |
with gr.Row():
|
| 689 |
with gr.Column(scale=2):
|
|
|
|
| 846 |
category_output
|
| 847 |
]
|
| 848 |
)
|
| 849 |
+
except Exception as interface_error:
|
| 850 |
+
logger.error(f"Error setting up Gradio interface components: {interface_error}", exc_info=True)
|
| 851 |
+
import traceback
|
| 852 |
+
error_trace = traceback.format_exc()
|
| 853 |
+
# Create a minimal working demo
|
| 854 |
+
with gr.Blocks(title="CGT-LLM-Beta RAG Chatbot") as demo:
|
| 855 |
+
gr.Markdown(f"""
|
| 856 |
+
# ⚠️ Interface Setup Error
|
| 857 |
+
|
| 858 |
+
An error occurred while setting up the interface components.
|
| 859 |
+
|
| 860 |
+
**Error:** {str(interface_error)}
|
| 861 |
+
|
| 862 |
+
**Traceback:**
|
| 863 |
+
```
|
| 864 |
+
{error_trace[:1000]}...
|
| 865 |
+
```
|
| 866 |
+
|
| 867 |
+
Please check the logs for more details.
|
| 868 |
+
""")
|
| 869 |
+
return demo
|
| 870 |
|
| 871 |
+
logger.info("Gradio interface created successfully")
|
| 872 |
return demo
|
| 873 |
|
| 874 |
|