Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -446,6 +446,23 @@ bot = RaindropSearchBot()
|
|
446 |
def chatbot_interface(user_input: str) -> str:
|
447 |
return bot.process_request(user_input)
|
448 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
# Define and launch the interface
|
450 |
with gr.Blocks(title="Enhanced Search Assistant", theme=gr.themes.Soft()) as demo:
|
451 |
gr.Markdown("""
|
@@ -467,18 +484,33 @@ with gr.Blocks(title="Enhanced Search Assistant", theme=gr.themes.Soft()) as dem
|
|
467 |
search_button = gr.Button("π Search", variant="primary")
|
468 |
|
469 |
with gr.Row():
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
|
476 |
search_button.click(
|
477 |
fn=chatbot_interface,
|
478 |
inputs=input_text,
|
479 |
outputs=output_text
|
480 |
-
)
|
481 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
# Launch the interface
|
483 |
if __name__ == "__main__":
|
484 |
demo.launch(share=True)
|
|
|
446 |
def chatbot_interface(user_input: str) -> str:
|
447 |
return bot.process_request(user_input)
|
448 |
|
449 |
+
def convert_to_markdown(output_text: str) -> gr.Markdown:
|
450 |
+
try:
|
451 |
+
# Create a new Gradio Markdown component with the output text
|
452 |
+
output_textMarkdown = gr.Markdown(
|
453 |
+
value=output_text,
|
454 |
+
render=True,
|
455 |
+
visible=True
|
456 |
+
)
|
457 |
+
return output_textMarkdown
|
458 |
+
except Exception as e:
|
459 |
+
logger.error(f"Error converting to markdown: {e}")
|
460 |
+
# Return error message as markdown if conversion fails
|
461 |
+
return gr.Markdown(
|
462 |
+
value="Error converting content to markdown format. Please try again.",
|
463 |
+
visible=True
|
464 |
+
)
|
465 |
+
|
466 |
# Define and launch the interface
|
467 |
with gr.Blocks(title="Enhanced Search Assistant", theme=gr.themes.Soft()) as demo:
|
468 |
gr.Markdown("""
|
|
|
484 |
search_button = gr.Button("π Search", variant="primary")
|
485 |
|
486 |
with gr.Row():
|
487 |
+
with gr.Accordion("Editable version"):
|
488 |
+
output_text = gr.Textbox(
|
489 |
+
label="Analysis and Results - editable",
|
490 |
+
lines=20,
|
491 |
+
interactive=True
|
492 |
+
)
|
493 |
+
refreshbutton = gr.Button("Refresh", variant="primary")
|
494 |
+
output_textMarkdown = gr.Markdown(
|
495 |
+
label="Analysis and Results",
|
496 |
+
height=200,
|
497 |
+
max_height=600
|
498 |
+
)
|
499 |
|
500 |
search_button.click(
|
501 |
fn=chatbot_interface,
|
502 |
inputs=input_text,
|
503 |
outputs=output_text
|
504 |
+
).then(
|
505 |
+
fn=convert_to_markdown,
|
506 |
+
inputs=output_text,
|
507 |
+
outputs=output_textMarkdown
|
508 |
+
|
509 |
+
refresh_button.click(
|
510 |
+
fn=convert_to_markdown,
|
511 |
+
inputs=output_text,
|
512 |
+
outputs=output_textMarkdown
|
513 |
+
|
514 |
# Launch the interface
|
515 |
if __name__ == "__main__":
|
516 |
demo.launch(share=True)
|