Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -439,47 +439,57 @@ def chatbot(user_input, science_objectives="", context="", subdomain="", use_enc
|
|
439 |
"""
|
440 |
return full_response, extracted_table_df, word_doc_path, iframe_html, mapify_button_html
|
441 |
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
label="Science
|
447 |
-
|
448 |
-
)
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
)
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
439 |
"""
|
440 |
return full_response, extracted_table_df, word_doc_path, iframe_html, mapify_button_html
|
441 |
|
442 |
+
with gr.Blocks() as demo:
|
443 |
+
gr.Markdown("# ExosAI - NASA SMD SCDD AI Assistant [version-0.91a]")
|
444 |
+
|
445 |
+
# User Inputs
|
446 |
+
user_input = gr.Textbox(lines=5, placeholder="Enter your Science Goal...", label="Science Goal")
|
447 |
+
context = gr.Textbox(lines=10, placeholder="Enter Context Text...", label="Context")
|
448 |
+
subdomain = gr.Textbox(lines=2, placeholder="Define your Subdomain...", label="Subdomain Definition")
|
449 |
+
|
450 |
+
# Science Objectives Button & Input (Initially Hidden)
|
451 |
+
science_objectives_button = gr.Button("Manually Enter Science Objectives")
|
452 |
+
science_objectives_input = gr.Textbox(
|
453 |
+
lines=5,
|
454 |
+
placeholder="Enter Science Objectives...",
|
455 |
+
label="Science Objectives",
|
456 |
+
visible=False # Initially hidden
|
457 |
+
)
|
458 |
+
|
459 |
+
# Define event inside Blocks (Fix for the Error)
|
460 |
+
science_objectives_button.click(
|
461 |
+
fn=lambda: gr.update(visible=True), # Show textbox when clicked
|
462 |
+
inputs=[],
|
463 |
+
outputs=[science_objectives_input]
|
464 |
+
)
|
465 |
+
|
466 |
+
# More Inputs
|
467 |
+
use_encoder = gr.Checkbox(label="Use NASA SMD Bi-Encoder for Context")
|
468 |
+
max_tokens = gr.Slider(50, 2000, value=150, step=10, label="Max Tokens")
|
469 |
+
temperature = gr.Slider(0.0, 1.0, value=0.7, step=0.1, label="Temperature")
|
470 |
+
top_p = gr.Slider(0.0, 1.0, value=0.9, step=0.1, label="Top-p")
|
471 |
+
frequency_penalty = gr.Slider(0.0, 1.0, value=0.5, step=0.1, label="Frequency Penalty")
|
472 |
+
presence_penalty = gr.Slider(0.0, 1.0, value=0.0, step=0.1, label="Presence Penalty")
|
473 |
+
|
474 |
+
# Outputs
|
475 |
+
full_response = gr.Textbox(label="ExosAI finds...")
|
476 |
+
extracted_table_df = gr.Dataframe(label="SC Requirements Table")
|
477 |
+
word_doc_path = gr.File(label="Download SCDD", type="filepath")
|
478 |
+
iframe_html = gr.HTML(label="Miro")
|
479 |
+
mapify_button_html = gr.HTML(label="Generate Mind Map on Mapify")
|
480 |
+
|
481 |
+
# Launch Button
|
482 |
+
submit_button = gr.Button("Generate Science Case")
|
483 |
+
|
484 |
+
# Define interaction: When the button is clicked, it triggers `chatbot`
|
485 |
+
submit_button.click(
|
486 |
+
fn=chatbot,
|
487 |
+
inputs=[
|
488 |
+
user_input, science_objectives_input, context, subdomain,
|
489 |
+
use_encoder, max_tokens, temperature, top_p, frequency_penalty, presence_penalty
|
490 |
+
],
|
491 |
+
outputs=[full_response, extracted_table_df, word_doc_path, iframe_html, mapify_button_html]
|
492 |
+
)
|
493 |
+
|
494 |
+
# Launch the app
|
495 |
+
demo.launch(share=True)
|