Chad commited on
Commit
5df60f7
·
1 Parent(s): c6a8aac

lang togglwdwdwdeeefefef

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -65,8 +65,17 @@ def toggle_language(language):
65
  "Who was the first person to step on the moon?"
66
  ]
67
 
68
- with gr.Blocks() as demo:
69
- language_state = gr.State("english")
 
 
 
 
 
 
 
 
 
70
  title = gr.Markdown("## History Chatbot")
71
  lang_button = gr.Button("FR")
72
  user_input = gr.Textbox(placeholder="Enter your question here...")
@@ -76,21 +85,14 @@ with gr.Blocks() as demo:
76
  send_button = gr.Button("Send")
77
 
78
  examples = gr.Examples(
79
- examples=[
80
- "How did the Leaning Tower of Pisa start leaning?",
81
- "Who built the Colosseum?",
82
- "What caused the fall of the Roman Empire?",
83
- "When did World War II begin and end?",
84
- "What was the significance of the Magna Carta?",
85
- "Who was the first person to step on the moon?"
86
- ],
87
  inputs=user_input
88
  )
89
 
90
  lang_button.click(
91
  fn=toggle_language,
92
  inputs=[language_state],
93
- outputs=[language_state, title, lang_button, user_input, examples]
94
  )
95
 
96
  send_button.click(
@@ -103,4 +105,4 @@ with gr.Blocks() as demo:
103
  reset_button.click(lambda: [], outputs=[state])
104
 
105
  if __name__ == "__main__":
106
- demo.launch(share=True)
 
65
  "Who was the first person to step on the moon?"
66
  ]
67
 
68
+ with gr.Blocks() as interface:
69
+ language_state = gr.State("english")
70
+ example_state = gr.State([
71
+ "How did the Leaning Tower of Pisa start leaning?",
72
+ "Who built the Colosseum?",
73
+ "What caused the fall of the Roman Empire?",
74
+ "When did World War II begin and end?",
75
+ "What was the significance of the Magna Carta?",
76
+ "Who was the first person to step on the moon?"
77
+ ])
78
+
79
  title = gr.Markdown("## History Chatbot")
80
  lang_button = gr.Button("FR")
81
  user_input = gr.Textbox(placeholder="Enter your question here...")
 
85
  send_button = gr.Button("Send")
86
 
87
  examples = gr.Examples(
88
+ examples=example_state.value,
 
 
 
 
 
 
 
89
  inputs=user_input
90
  )
91
 
92
  lang_button.click(
93
  fn=toggle_language,
94
  inputs=[language_state],
95
+ outputs=[language_state, title, lang_button, user_input, example_state]
96
  )
97
 
98
  send_button.click(
 
105
  reset_button.click(lambda: [], outputs=[state])
106
 
107
  if __name__ == "__main__":
108
+ interface.launch(share=True)