Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,8 +109,8 @@ def format_history_for_gradio(history_tuples):
|
|
| 109 |
Convert a list of (user_msg, bot_msg) tuples
|
| 110 |
into a list of dicts for 'type="messages"':
|
| 111 |
[
|
| 112 |
-
{"role": "user", "content":
|
| 113 |
-
{"role": "assistant", "content":
|
| 114 |
...
|
| 115 |
]
|
| 116 |
"""
|
|
@@ -254,6 +254,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 254 |
button_updates.append(gr.Button.update(value="(no starter)", visible=False))
|
| 255 |
return button_updates
|
| 256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
# Function that populates the msg with the chosen starter text, then calls respond
|
| 258 |
def pick_starter(starter_text, chat_history, selected_genre, memory_flag):
|
| 259 |
return starter_text # This goes into 'msg'
|
|
@@ -274,7 +280,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 274 |
queue=False
|
| 275 |
)
|
| 276 |
|
| 277 |
-
# Connect the genre dropdown to update
|
| 278 |
genre.change(
|
| 279 |
fn=update_starter_buttons,
|
| 280 |
inputs=[genre],
|
|
|
|
| 109 |
Convert a list of (user_msg, bot_msg) tuples
|
| 110 |
into a list of dicts for 'type="messages"':
|
| 111 |
[
|
| 112 |
+
{"role": "user", "content": ...},
|
| 113 |
+
{"role": "assistant", "content": ...},
|
| 114 |
...
|
| 115 |
]
|
| 116 |
"""
|
|
|
|
| 254 |
button_updates.append(gr.Button.update(value="(no starter)", visible=False))
|
| 255 |
return button_updates
|
| 256 |
|
| 257 |
+
# Initialize the starter buttons with the default 'fantasy' prompts
|
| 258 |
+
# so they don't stay "Starter 1/2/3/4" on page load.
|
| 259 |
+
starter_init = update_starter_buttons("fantasy")
|
| 260 |
+
for btn, init_data in zip(starter_buttons, starter_init):
|
| 261 |
+
btn.update(**init_data)
|
| 262 |
+
|
| 263 |
# Function that populates the msg with the chosen starter text, then calls respond
|
| 264 |
def pick_starter(starter_text, chat_history, selected_genre, memory_flag):
|
| 265 |
return starter_text # This goes into 'msg'
|
|
|
|
| 280 |
queue=False
|
| 281 |
)
|
| 282 |
|
| 283 |
+
# Connect the genre dropdown to dynamically update starter buttons
|
| 284 |
genre.change(
|
| 285 |
fn=update_starter_buttons,
|
| 286 |
inputs=[genre],
|