Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -293,12 +293,8 @@ def main():
|
|
| 293 |
# Launch Gradio interface
|
| 294 |
logger.info("Launching Gradio interface...")
|
| 295 |
|
| 296 |
-
#
|
| 297 |
-
|
| 298 |
-
gradio_version = tuple(map(int, gradio.__version__.split('.')[:2]))
|
| 299 |
-
|
| 300 |
-
if gradio_version >= (4, 0):
|
| 301 |
-
# Gradio 4.x+ - supports custom button labels
|
| 302 |
demo = gr.ChatInterface(
|
| 303 |
fn=chat_fn,
|
| 304 |
title="PI Policy Chatbot",
|
|
@@ -316,8 +312,9 @@ def main():
|
|
| 316 |
undo_btn="Delete Previous",
|
| 317 |
clear_btn="Clear Chat",
|
| 318 |
)
|
| 319 |
-
|
| 320 |
-
# Gradio 3.x
|
|
|
|
| 321 |
demo = gr.ChatInterface(
|
| 322 |
fn=chat_fn,
|
| 323 |
title="PI Policy Chatbot",
|
|
|
|
| 293 |
# Launch Gradio interface
|
| 294 |
logger.info("Launching Gradio interface...")
|
| 295 |
|
| 296 |
+
# Try with new Gradio parameters, fall back to basic if not supported
|
| 297 |
+
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
demo = gr.ChatInterface(
|
| 299 |
fn=chat_fn,
|
| 300 |
title="PI Policy Chatbot",
|
|
|
|
| 312 |
undo_btn="Delete Previous",
|
| 313 |
clear_btn="Clear Chat",
|
| 314 |
)
|
| 315 |
+
except TypeError:
|
| 316 |
+
# Fall back to basic Gradio 3.x parameters
|
| 317 |
+
logger.info("Using Gradio 3.x compatible parameters")
|
| 318 |
demo = gr.ChatInterface(
|
| 319 |
fn=chat_fn,
|
| 320 |
title="PI Policy Chatbot",
|