itsalissonsilva commited on
Commit
1ecd6f3
·
verified ·
1 Parent(s): 2c853f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -6,7 +6,6 @@ model_name = "distilgpt2"
6
  tokenizer = AutoTokenizer.from_pretrained(model_name)
7
  model = AutoModelForCausalLM.from_pretrained(model_name)
8
 
9
- # Sample starting scenario and choices
10
  scenario = "You wake up in a strange forest. Paths lead in all directions."
11
  choices = [
12
  "Walk north into the dense forest.",
@@ -30,14 +29,12 @@ def update_scenario(choice_index):
30
  new_scenario = generate_continuation(chosen_action)
31
  return new_scenario
32
 
33
- # Gradio app
34
  with gr.Blocks() as app:
35
  with gr.Row():
36
  story_display = gr.Textbox(value=scenario, show_label=False, lines=7)
 
37
 
38
- with gr.Row():
39
- for i, choice in enumerate(choices):
40
- button = gr.Button(choice)
41
- button.click(fn=update_scenario, data=i, outputs=story_display)
42
 
43
  app.launch()
 
6
  tokenizer = AutoTokenizer.from_pretrained(model_name)
7
  model = AutoModelForCausalLM.from_pretrained(model_name)
8
 
 
9
  scenario = "You wake up in a strange forest. Paths lead in all directions."
10
  choices = [
11
  "Walk north into the dense forest.",
 
29
  new_scenario = generate_continuation(chosen_action)
30
  return new_scenario
31
 
 
32
  with gr.Blocks() as app:
33
  with gr.Row():
34
  story_display = gr.Textbox(value=scenario, show_label=False, lines=7)
35
+ choice_buttons = [gr.Button(choice) for choice in choices]
36
 
37
+ for i, button in enumerate(choice_buttons):
38
+ button.click(fn=lambda x=i: update_scenario(x), inputs=None, outputs=story_display)
 
 
39
 
40
  app.launch()