imamnurby commited on
Commit
f544409
1 Parent(s): c0dde66

fix try sample button and description

Browse files
Files changed (1) hide show
  1. app.py +43 -33
app.py CHANGED
@@ -365,40 +365,43 @@ def generate_channel(input_desc, n_beams_discover):
365
  ###
366
  demo = gr.Blocks()
367
  with demo:
368
- gr.Markdown("<h1><center>RecipeGen: an Automated Trigger Action Programs (TAPs) Generation Tool</center></h1>")
369
  # gr.Markdown("This demo allows you to generate TAPs using functionality description described in English. You can learn the working detail of our tool from our paper")
370
  gr.Markdown("<h3>What is TAP?</h3>")
371
  gr.Markdown("""
372
- TAPs or Trigger Action Programs are event-driven rules used to automate smart devices and/or internet services. TAPs are written in the form of "IF a **{trigger}** is
373
- satisfied then execute an **{action}**, where the **{trigger}** and the **{action}** correspond to API calls. TAPs have been used in various use cases, ranging from home monitoring
374
- system to business workflow automation.
375
  """)
376
- gr.Markdown("<h3>What is RecipeGen?</h3>")
377
  gr.Markdown("""
378
- RecipeGen is a deep learning-based tool that can assist end-users to generate TAPs using natural language description. End-users can describe the functionality of the intended TAP, then RecipeGen
379
- will generate the TAP candidates based on the given description.
380
  """)
381
  gr.Markdown("<h3>Working Mode</h3>")
382
  gr.Markdown("""
383
- - Interactive: generate a TAP using step-by-step wizard
384
- - One Click: generate a TAP using one click button
385
- - Function Discovery: Discover relevant functionalities from channels with a similar functionalities
386
  """)
387
  with gr.Tabs():
388
  with gr.TabItem("Interactive"):
389
  gr.Markdown("<h3><center>Instructions for Interactive Mode</center></h3>")
390
  gr.Markdown("""1. There are 5 generation steps, i.e., generating trigger channel, trigger function, action channel, action function, and the final TAP.
391
- 2. **[STEP 1]** Describe the functionality in the `Functionality Description` text box. Click `Generate Trigger Channel` button. The channel candidates and their descriptions will show up in the `Trigger Channel Results` table.
392
- 3. **[STEP 2]** Select a trigger channel from the dropdown `Select the Trigger Channel`. Click `Generate Trigger Function` button. The function candidates and their descriptions will show up in the `Trigger Function Results` table.
393
- 4. **[STEP 3]** Select a trigger function from the dropdown `Select the Trigger Function`. Click `Generate Action Channel` button. The channel candidates and their descriptions will show up in the `Action Channel Results` table.
394
- 5. **[STEP 4]** Select an action channel from the dropdown `Select the Action Channel`. Click `Generate Action Function` button. The function candidates and their descriptions will show up in the `Action Function Results` table.
395
- 6. **[STEP 5]** Select an action function from the `Select the Action Function` to generate the final TAP.""")
396
- gr.Markdown(""" NOTE: You can control how many sequences are returned by tuning the `Beam Width` slider. Larger value will cause longer generation time.
397
  """)
398
 
399
  with gr.Box():
400
  with gr.Column():
401
- dropdown_example = gr.Dropdown(type ="value",choices = ["Log to my spreadsheet if motion is detected in the living room","Notify me when someone open the front door", "Turn on my Philips lamp every sunset","Update my picture in Twitter when I change my profile picture in Facebook","Send and append to my note when I create a new bookmark"], label = "Here are some sample functionality descriptions that you can try")
 
 
 
402
  button_use_example = gr.Button("Try this sample")
403
 
404
  with gr.Box():
@@ -455,6 +458,7 @@ with demo:
455
  table_final = gr.Dataframe(headers=["Trigger","Action"], row_count=1)
456
 
457
  button_use_example.click(return_same, inputs=[dropdown_example], outputs=[textbox_input])
 
458
  button_generate_tc.click(generate_preds_tc, inputs=[textbox_input, n_beams_interactive], outputs=[table_tc])
459
 
460
  table_tc.change(fn=update_dropdown_trig_ch, inputs=[table_tc], outputs=[dropdown_tc])
@@ -472,18 +476,20 @@ with demo:
472
  table_af.change(fn=update_dropdown_action_func, inputs=[table_af], outputs=[dropdown_af])
473
  dropdown_af.change(fn=set_final_result, inputs=[textbox_selected_tf, table_af, dropdown_af], outputs=[table_final])
474
 
475
- with gr.TabItem("One Click"):
476
- gr.Markdown("<h3><center>Instructions for One Click Mode</center></h3>")
477
  gr.Markdown("""
478
- 1. Describe the functionality in the `Functionality Description` text box.
479
- 2. Click `Generate TAP` button. The TAP candidates will show up in the `TAP Results` table. The table consists of 4 columns: Trigger, Action, Trigger Description, and Action Description. You can scroll the table vertically.
480
  """)
481
- gr.Markdown(""" NOTE: You can control how many sequences are returned by tuning the `Beam Width` slider. Larger value will cause longer generation time.""")
482
 
483
  with gr.Box():
484
  with gr.Column():
485
- gr.Markdown("You can try some description samples below:")
486
- dropdown_example = gr.Dropdown(type ="value",choices = ["Log to my spreadsheet if motion is detected in the living room","Notify me when someone open the front door", "Turn on my Philips lamp every sunset","Update my picture in Twitter when I change my profile picture in Facebook","Send and append to my note when I create a new bookmark"], label = "Here are some sample functionality descriptions that you can try")
 
 
487
  button_use_example = gr.Button("Try this sample")
488
 
489
  with gr.Box():
@@ -496,21 +502,24 @@ with demo:
496
  gr.Markdown("<h4><center>TAP Results</center></h4>")
497
  table_oneshot = gr.Dataframe(headers=["Trigger", "Action", "Trigger Description", "Action Description"], row_count=1)
498
 
499
- button_use_example.click(return_same, inputs=[dropdown_example], outputs=[textbox_input])
 
500
  button_generate_oneshot.click(generate_oneshot, inputs=[textbox_input, n_beams_oneshot], outputs=[table_oneshot])
501
 
502
- with gr.TabItem("Function Discovery"):
503
- gr.Markdown("<h3><center>Instructions for One-shot Mode</center></h3>")
504
  gr.Markdown("""
505
  1. Describe the functionality in the `Functionality Description` text box.
506
- 2. Click `Discover Functioanlities` button. The table containing relevant trigger and action channels will show up. Each channel is accompanied by a list of available functionalities.
507
  """)
508
- gr.Markdown(""" NOTE: You can control how many sequences are returned by tuning the `Beam Width` slider. Larger value will cause longer generation time.""")
509
 
510
  with gr.Box():
511
  with gr.Column():
512
- gr.Markdown("You can try some description samples below:")
513
- dropdown_example = gr.Dropdown(type ="value",choices = ["Log to my spreadsheet if motion is detected in the living room","Notify me when someone open the front door", "Turn on my Philips lamp every sunset","Update my picture in Twitter when I change my profile picture in Facebook","Send and append to my note when I create a new bookmark"], label = "Here are some sample functionality descriptions that you can try")
 
 
514
  button_use_example = gr.Button("Try this sample")
515
 
516
  with gr.Box():
@@ -520,14 +529,15 @@ with demo:
520
  button_discover_function = gr.Button("Discover Functions!")
521
 
522
  gr.Markdown("<br>")
523
- gr.Markdown("<h4><center>Relevant Trigger Channels</center></h4>")
524
  table_discover_tc = gr.Dataframe(headers=["Trigger", "Available Functions", "Trigger Description"], row_count=1)
525
 
526
  gr.Markdown("<br>")
527
- gr.Markdown("<h4><center>Relevant Action Channels</center></h4>")
528
  table_discover_ac = gr.Dataframe(headers=["Action", "Available Functions", "Action Description"], row_count=1)
529
 
530
  button_use_example.click(return_same, inputs=[dropdown_example], outputs=[textbox_input])
 
531
  button_discover_function.click(generate_channel, inputs=[textbox_input, n_beams_discover], outputs=[table_discover_tc, table_discover_ac])
532
 
533
  demo.launch()
365
  ###
366
  demo = gr.Blocks()
367
  with demo:
368
+ gr.Markdown("<h1><center><em>RecipeGen++</em> | an Automated Trigger Action Programs (TAPs) Generation Tool</center></h1>")
369
  # gr.Markdown("This demo allows you to generate TAPs using functionality description described in English. You can learn the working detail of our tool from our paper")
370
  gr.Markdown("<h3>What is TAP?</h3>")
371
  gr.Markdown("""
372
+ TAPs or Trigger Action Programs are event-driven rules used to automate smart devices and/or internet services.
373
+ TAPs are written in the form of "IF a {trigger} is satisfied then execute an {action}, where the {trigger} and the {action} correspond to API calls.
374
+ TAPs have been used in various use cases, ranging from the home monitoring system to business workflow automation.
375
  """)
376
+ gr.Markdown("<h3>What is <em>RecipeGen++</em>?</h3>")
377
  gr.Markdown("""
378
+ *RecipeGen++* is a deep learning-based tool that can assist end-users to generate TAPs using natural language description.
379
+ End-users can describe the functionality of the intended TAP, then *RecipeGen++* will generate the TAP candidates based on the given description.
380
  """)
381
  gr.Markdown("<h3>Working Mode</h3>")
382
  gr.Markdown("""
383
+ - Interactive: generate a TAP using a step-by-step wizard
384
+ - One-Click: generate a TAP using the one-click button
385
+ - Functionality Discovery: discover relevant functionalities from channels with similar functionalities
386
  """)
387
  with gr.Tabs():
388
  with gr.TabItem("Interactive"):
389
  gr.Markdown("<h3><center>Instructions for Interactive Mode</center></h3>")
390
  gr.Markdown("""1. There are 5 generation steps, i.e., generating trigger channel, trigger function, action channel, action function, and the final TAP.
391
+ 2. **[STEP 1]** Describe the functionality in the `Functionality Description` text box. Click the `Generate Trigger Channel` button. The channel candidates and their descriptions will show up in the `Trigger Channel Results` table.
392
+ 3. **[STEP 2]** Select a trigger channel from the dropdown `Select the Trigger Channel`. Click the `Generate Trigger Function` button. The function candidates and their descriptions will show up in the `Trigger Function Results` table.
393
+ 4. **[STEP 3]** Select a trigger function from the dropdown `Select the Trigger Function`. Click the `Generate Action Channel` button. The channel candidates and their descriptions will show up in the `Action Channel Results` table.
394
+ 5. **[STEP 4]** Select an action channel from the dropdown `Select the Action Channel`. Click the `Generate Action Function` button. The function candidates and their descriptions will show up in the `Action Function Results` table.
395
+ 6. **[STEP 5]** Select an action function from the `Select the Action Function` to generate the final TAP.""")
396
+ gr.Markdown(""" NOTE: You can control how many sequences are returned by tuning the `Beam Width` slider. A larger value will cause a longer generation time.
397
  """)
398
 
399
  with gr.Box():
400
  with gr.Column():
401
+ gr.Markdown("You can describe your own functionality directly in the `Functionality Description` text box or try a description sample from the dropdown below:")
402
+ dropdown_example = gr.Dropdown(type ="value",
403
+ choices = ["Log to my spreadsheet if motion is detected in the living room","When I am not home, let me know when any motion is detected in my house", "Turn on my Philips lamp every sunset","Update my picture in Twitter when I change my profile picture in Facebook","Save in notes when I create a new bookmark"],
404
+ label = "Select a sample functionality descriptions")
405
  button_use_example = gr.Button("Try this sample")
406
 
407
  with gr.Box():
458
  table_final = gr.Dataframe(headers=["Trigger","Action"], row_count=1)
459
 
460
  button_use_example.click(return_same, inputs=[dropdown_example], outputs=[textbox_input])
461
+ button_use_example.click(generate_preds_tc, inputs=[dropdown_example, n_beams_interactive], outputs=[table_tc])
462
  button_generate_tc.click(generate_preds_tc, inputs=[textbox_input, n_beams_interactive], outputs=[table_tc])
463
 
464
  table_tc.change(fn=update_dropdown_trig_ch, inputs=[table_tc], outputs=[dropdown_tc])
476
  table_af.change(fn=update_dropdown_action_func, inputs=[table_af], outputs=[dropdown_af])
477
  dropdown_af.change(fn=set_final_result, inputs=[textbox_selected_tf, table_af, dropdown_af], outputs=[table_final])
478
 
479
+ with gr.TabItem("One-Click"):
480
+ gr.Markdown("<h3><center>Instructions for One-Click Mode</center></h3>")
481
  gr.Markdown("""
482
+ 1. Describe the functionality by yourself in the `Functionality Description` text box
483
+ 2. Click `Generate TAP` button. The TAP candidates will show up in the `TAP Results` table. The table consists of 4 columns: Trigger, Action, Trigger Description, and Action Description. You can scroll the table horizontally.
484
  """)
485
+ gr.Markdown(""" NOTE: You can control how many sequences are returned by tuning the `Beam Width` slider. A larger value will cause a longer generation time.""")
486
 
487
  with gr.Box():
488
  with gr.Column():
489
+ gr.Markdown("You can describe your own functionality directly in the `Functionality Description` text box or try a description sample from the dropdown below:")
490
+ dropdown_example = gr.Dropdown(type ="value",
491
+ choices = ["Log to my spreadsheet if motion is detected in the living room","When I am not home, let me know when any motion is detected in my house", "Turn on my Philips lamp every sunset","Update my picture in Twitter when I change my profile picture in Facebook","Save in notes when I create a new bookmark"],
492
+ label = "Select a sample functionality description")
493
  button_use_example = gr.Button("Try this sample")
494
 
495
  with gr.Box():
502
  gr.Markdown("<h4><center>TAP Results</center></h4>")
503
  table_oneshot = gr.Dataframe(headers=["Trigger", "Action", "Trigger Description", "Action Description"], row_count=1)
504
 
505
+ button_use_example.click(return_same, inputs=[dropdown_example], outputs=[textbox_input])
506
+ button_use_example.click(generate_oneshot, inputs=[dropdown_example, n_beams_oneshot], outputs=[table_oneshot])
507
  button_generate_oneshot.click(generate_oneshot, inputs=[textbox_input, n_beams_oneshot], outputs=[table_oneshot])
508
 
509
+ with gr.TabItem("Functionality Discovery"):
510
+ gr.Markdown("<h3><center>Instructions for Functionality Discovery Mode</center></h3>")
511
  gr.Markdown("""
512
  1. Describe the functionality in the `Functionality Description` text box.
513
+ 2. Click `Discover Functionalities` button. The table containing relevant trigger and action channels will show up. Each channel is accompanied by a list of available functionalities. You can scroll the table horizontally.
514
  """)
515
+ gr.Markdown(""" NOTE: You can control how many sequences are returned by tuning the `Beam Width` slider. A larger value will cause a longer generation time.""")
516
 
517
  with gr.Box():
518
  with gr.Column():
519
+ gr.Markdown("You can describe your own functionality directly in the `Functionality Description` text box or try a description sample from the dropdown below:")
520
+ dropdown_example = gr.Dropdown(type ="value",
521
+ choices = ["Log to my spreadsheet if motion is detected in the living room","When I am not home, let me know when any motion is detected in my house", "Turn on my Philips lamp every sunset","Update my picture in Twitter when I change my profile picture in Facebook","Save in notes when I create a new bookmark"],
522
+ label = "Select a sample functionality description")
523
  button_use_example = gr.Button("Try this sample")
524
 
525
  with gr.Box():
529
  button_discover_function = gr.Button("Discover Functions!")
530
 
531
  gr.Markdown("<br>")
532
+ gr.Markdown("<h4><center>Relevant Trigger Channels and Functionalities</center></h4>")
533
  table_discover_tc = gr.Dataframe(headers=["Trigger", "Available Functions", "Trigger Description"], row_count=1)
534
 
535
  gr.Markdown("<br>")
536
+ gr.Markdown("<h4><center>Relevant Action Channels and Functionalities</center></h4>")
537
  table_discover_ac = gr.Dataframe(headers=["Action", "Available Functions", "Action Description"], row_count=1)
538
 
539
  button_use_example.click(return_same, inputs=[dropdown_example], outputs=[textbox_input])
540
+ button_use_example.click(generate_channel, inputs=[dropdown_example, n_beams_discover], outputs=[table_discover_tc, table_discover_ac])
541
  button_discover_function.click(generate_channel, inputs=[textbox_input, n_beams_discover], outputs=[table_discover_tc, table_discover_ac])
542
 
543
  demo.launch()