aquibmoin commited on
Commit
33d1fed
·
verified ·
1 Parent(s): 1a0e54f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -44
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
- science_objectives_button = gr.Button("Manually Enter Science Objectives")
443
- science_objectives_input = gr.Textbox(
444
- lines=5,
445
- placeholder="Enter Science Objectives...",
446
- label="Science Objectives",
447
- visible=False # Initially hidden
448
- )
449
-
450
- def show_science_objectives():
451
- return gr.update(visible=True)
452
-
453
- science_objectives_button.click(
454
- show_science_objectives, # Function to call
455
- inputs=[], # No inputs needed
456
- outputs=[science_objectives_input] # Target output
457
- )
458
-
459
- iface = gr.Interface(
460
- fn=chatbot,
461
- inputs=[
462
- gr.Textbox(lines=5, placeholder="Enter your Science Goal...", label="Science Goal"),
463
- gr.Textbox(lines=10, placeholder="Enter Context Text...", label="Context"),
464
- gr.Textbox(lines=2, placeholder="Define your Subdomain...", label="Subdomain Definition"),
465
- science_objectives_button, # Button to show the textbox
466
- science_objectives_input, # Initially hidden textbox
467
- gr.Checkbox(label="Use NASA SMD Bi-Encoder for Context"),
468
- gr.Slider(50, 2000, value=150, step=10, label="Max Tokens"),
469
- gr.Slider(0.0, 1.0, value=0.7, step=0.1, label="Temperature"),
470
- gr.Slider(0.0, 1.0, value=0.9, step=0.1, label="Top-p"),
471
- gr.Slider(0.0, 1.0, value=0.5, step=0.1, label="Frequency Penalty"),
472
- gr.Slider(0.0, 1.0, value=0.0, step=0.1, label="Presence Penalty")
473
- ],
474
- outputs=[
475
- gr.Textbox(label="ExosAI finds..."),
476
- gr.Dataframe(label="SC Requirements Table"),
477
- gr.File(label="Download SCDD", type="filepath"),
478
- gr.HTML(label="Miro"),
479
- gr.HTML(label="Generate Mind Map on Mapify")
480
- ],
481
- title="ExosAI - NASA SMD SCDD AI Assistant [version-0.91a]",
482
- description="ExosAI is an AI-powered assistant for generating and visualising HWO Science Cases",
483
- )
484
-
485
- iface.launch(share=True)
 
 
 
 
 
 
 
 
 
 
 
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)