Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -232,19 +232,20 @@ def launch():
|
|
| 232 |
)
|
| 233 |
|
| 234 |
with gr.Blocks(title="Conversation Learning Lab (CPU)") as demo:
|
|
|
|
| 235 |
gr.Markdown("# 🗣️ Conversation Learning Lab (CPU-friendly)")
|
| 236 |
gr.Markdown(
|
| 237 |
"Focus on daily dialogue. Reinforce validated language blocks. "
|
| 238 |
"Transparent tokens and latency."
|
| 239 |
)
|
| 240 |
|
|
|
|
| 241 |
with gr.Row():
|
| 242 |
model_dd = gr.Dropdown(
|
| 243 |
label="Choose a model",
|
| 244 |
choices=list(MODEL_OPTIONS.keys()),
|
| 245 |
value="Phi-3.5 Mini Instruct (4B)"
|
| 246 |
)
|
| 247 |
-
|
| 248 |
with gr.Row():
|
| 249 |
user_in = gr.Textbox(
|
| 250 |
label="Your message",
|
|
@@ -252,29 +253,32 @@ def launch():
|
|
| 252 |
lines=3
|
| 253 |
)
|
| 254 |
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
|
|
|
|
| 262 |
with gr.Row():
|
| 263 |
generate_btn = gr.Button("Generate (CPU)")
|
| 264 |
-
reflect_btn = gr.Button("Reflect & Save Rule")
|
| 265 |
|
|
|
|
| 266 |
with gr.Row():
|
| 267 |
output = gr.Textbox(label="Assistant", lines=8)
|
| 268 |
-
|
| 269 |
with gr.Row():
|
| 270 |
metrics = gr.Markdown("")
|
| 271 |
|
| 272 |
-
#
|
| 273 |
-
gr.Markdown("###
|
| 274 |
-
gr.
|
| 275 |
-
|
| 276 |
-
|
|
|
|
| 277 |
)
|
|
|
|
|
|
|
| 278 |
|
| 279 |
# Wire up events
|
| 280 |
generate_btn.click(
|
|
@@ -282,7 +286,6 @@ def launch():
|
|
| 282 |
inputs=[user_in, model_dd, blocks_editor],
|
| 283 |
outputs=[output, metrics]
|
| 284 |
)
|
| 285 |
-
|
| 286 |
reflect_btn.click(
|
| 287 |
fn=reflect_and_save,
|
| 288 |
inputs=[user_in, output, blocks_editor],
|
|
@@ -291,6 +294,5 @@ def launch():
|
|
| 291 |
|
| 292 |
demo.launch()
|
| 293 |
|
| 294 |
-
|
| 295 |
if __name__ == "__main__":
|
| 296 |
-
launch()
|
|
|
|
| 232 |
)
|
| 233 |
|
| 234 |
with gr.Blocks(title="Conversation Learning Lab (CPU)") as demo:
|
| 235 |
+
# Header
|
| 236 |
gr.Markdown("# 🗣️ Conversation Learning Lab (CPU-friendly)")
|
| 237 |
gr.Markdown(
|
| 238 |
"Focus on daily dialogue. Reinforce validated language blocks. "
|
| 239 |
"Transparent tokens and latency."
|
| 240 |
)
|
| 241 |
|
| 242 |
+
# Model selector + input
|
| 243 |
with gr.Row():
|
| 244 |
model_dd = gr.Dropdown(
|
| 245 |
label="Choose a model",
|
| 246 |
choices=list(MODEL_OPTIONS.keys()),
|
| 247 |
value="Phi-3.5 Mini Instruct (4B)"
|
| 248 |
)
|
|
|
|
| 249 |
with gr.Row():
|
| 250 |
user_in = gr.Textbox(
|
| 251 |
label="Your message",
|
|
|
|
| 253 |
lines=3
|
| 254 |
)
|
| 255 |
|
| 256 |
+
# Example prompts
|
| 257 |
+
gr.Markdown("### 🧪 Try an example prompt:")
|
| 258 |
+
gr.Examples(
|
| 259 |
+
examples=EXAMPLES,
|
| 260 |
+
inputs=user_in
|
| 261 |
+
)
|
| 262 |
|
| 263 |
+
# Generate button comes right after examples
|
| 264 |
with gr.Row():
|
| 265 |
generate_btn = gr.Button("Generate (CPU)")
|
|
|
|
| 266 |
|
| 267 |
+
# Output + metrics
|
| 268 |
with gr.Row():
|
| 269 |
output = gr.Textbox(label="Assistant", lines=8)
|
|
|
|
| 270 |
with gr.Row():
|
| 271 |
metrics = gr.Markdown("")
|
| 272 |
|
| 273 |
+
# JSON blocks editor + Reflect button at the bottom
|
| 274 |
+
gr.Markdown("### 📋 Today's Blocks")
|
| 275 |
+
blocks_editor = gr.Textbox(
|
| 276 |
+
label="Editable rules (JSON array or 'type: rule' lines)",
|
| 277 |
+
value=default_blocks_text,
|
| 278 |
+
lines=10
|
| 279 |
)
|
| 280 |
+
with gr.Row():
|
| 281 |
+
reflect_btn = gr.Button("Reflect & Save Rule")
|
| 282 |
|
| 283 |
# Wire up events
|
| 284 |
generate_btn.click(
|
|
|
|
| 286 |
inputs=[user_in, model_dd, blocks_editor],
|
| 287 |
outputs=[output, metrics]
|
| 288 |
)
|
|
|
|
| 289 |
reflect_btn.click(
|
| 290 |
fn=reflect_and_save,
|
| 291 |
inputs=[user_in, output, blocks_editor],
|
|
|
|
| 294 |
|
| 295 |
demo.launch()
|
| 296 |
|
|
|
|
| 297 |
if __name__ == "__main__":
|
| 298 |
+
launch()
|