Update app.py
Browse files
app.py
CHANGED
@@ -33,9 +33,11 @@ def generate_response(user_input, max_new_tokens, temperature):
|
|
33 |
gen_text = tokenizer.decode(gen_tokens[0])
|
34 |
return gen_text
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
39 |
|
40 |
examples = [
|
41 |
{"message": "What is the weather like today?", "max_new_tokens": 250, "temperature": 0.5},
|
@@ -57,11 +59,12 @@ with gr.Blocks() as demo:
|
|
57 |
inputs=[message_box, max_new_tokens_slider, temperature_slider],
|
58 |
outputs=output_box
|
59 |
)
|
60 |
-
example_dropdown = gr.Dropdown(label="Load Example", choices=
|
61 |
-
example_button = gr.Button("Load")
|
62 |
example_button.click(
|
63 |
fn=load_example,
|
64 |
inputs=example_dropdown,
|
65 |
outputs=[message_box, max_new_tokens_slider, temperature_slider]
|
66 |
)
|
67 |
-
|
|
|
|
33 |
gen_text = tokenizer.decode(gen_tokens[0])
|
34 |
return gen_text
|
35 |
|
36 |
+
example_choices = {f"Example {i+1}": example for i, example in enumerate(examples)}
|
37 |
+
|
38 |
+
def load_example(choice):
|
39 |
+
example = example_choices[choice]
|
40 |
+
return example
|
41 |
|
42 |
examples = [
|
43 |
{"message": "What is the weather like today?", "max_new_tokens": 250, "temperature": 0.5},
|
|
|
59 |
inputs=[message_box, max_new_tokens_slider, temperature_slider],
|
60 |
outputs=output_box
|
61 |
)
|
62 |
+
example_dropdown = gr.Dropdown(label="🫡Load Example", choices=list(example_choices.keys()))
|
63 |
+
example_button = gr.Button("🫡Load")
|
64 |
example_button.click(
|
65 |
fn=load_example,
|
66 |
inputs=example_dropdown,
|
67 |
outputs=[message_box, max_new_tokens_slider, temperature_slider]
|
68 |
)
|
69 |
+
|
70 |
+
demo.launch()
|