Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -116,6 +116,8 @@ def reset_user_input():
|
|
116 |
def reset_state():
|
117 |
return [], []
|
118 |
|
|
|
|
|
119 |
|
120 |
with gr.Blocks() as demo:
|
121 |
gr.HTML("""<h1 align="center">Prompt Preference Optimizer</h1>""")
|
@@ -124,7 +126,9 @@ with gr.Blocks() as demo:
|
|
124 |
with gr.Row():
|
125 |
with gr.Column(scale=4):
|
126 |
with gr.Column(scale=12):
|
127 |
-
|
|
|
|
|
128 |
with gr.Column(min_width=32, scale=1):
|
129 |
submitBtn = gr.Button("Submit", variant="primary")
|
130 |
with gr.Column(scale=1):
|
@@ -133,6 +137,8 @@ with gr.Blocks() as demo:
|
|
133 |
top_p = gr.Slider(0, 1, value=0.9, step=0.01, label="Top P", interactive=True)
|
134 |
temperature = gr.Slider(0, 1, value=0.6, step=0.01, label="Temperature", interactive=True)
|
135 |
|
|
|
|
|
136 |
history = gr.State([])
|
137 |
|
138 |
submitBtn.click(predict, [user_input, chatbot, max_length, top_p, temperature, history], [chatbot, history],
|
|
|
116 |
def reset_state():
|
117 |
return [], []
|
118 |
|
119 |
+
def update_textbox_from_dropdown(selected_example):
|
120 |
+
return selected_example
|
121 |
|
122 |
with gr.Blocks() as demo:
|
123 |
gr.HTML("""<h1 align="center">Prompt Preference Optimizer</h1>""")
|
|
|
126 |
with gr.Row():
|
127 |
with gr.Column(scale=4):
|
128 |
with gr.Column(scale=12):
|
129 |
+
dropdown = gr.Dropdown(["tell me about harry potter", "give me 3 tips to learn English", "write a story about love"], label="Choose an example input")
|
130 |
+
user_input = gr.Textbox(show_label=False, placeholder="User Prompt...", lines=5).style(
|
131 |
+
container=False)
|
132 |
with gr.Column(min_width=32, scale=1):
|
133 |
submitBtn = gr.Button("Submit", variant="primary")
|
134 |
with gr.Column(scale=1):
|
|
|
137 |
top_p = gr.Slider(0, 1, value=0.9, step=0.01, label="Top P", interactive=True)
|
138 |
temperature = gr.Slider(0, 1, value=0.6, step=0.01, label="Temperature", interactive=True)
|
139 |
|
140 |
+
dropdown.change(update_textbox_from_dropdown, dropdown, user_input)
|
141 |
+
|
142 |
history = gr.State([])
|
143 |
|
144 |
submitBtn.click(predict, [user_input, chatbot, max_length, top_p, temperature, history], [chatbot, history],
|