Update app.py
Browse files
app.py
CHANGED
|
@@ -295,30 +295,34 @@ prompt_examples = [
|
|
| 295 |
"A concept art of"
|
| 296 |
]
|
| 297 |
|
| 298 |
-
#
|
| 299 |
-
prompt_examples = prompt_list
|
| 300 |
|
| 301 |
-
# Fonction de génération
|
| 302 |
def generate(prompt, n):
|
| 303 |
return "\n\n---\n\n".join(
|
| 304 |
prompt + llm(prompt, max_tokens=200, stop=["</s>"], echo=False)["choices"][0]["text"]
|
| 305 |
for _ in range(n)
|
| 306 |
)
|
| 307 |
|
| 308 |
-
# Fonction: randomise un prompt (sans générer)
|
| 309 |
def pick_random_prompt():
|
| 310 |
return random.choice(prompt_list)
|
| 311 |
|
| 312 |
-
# Fonction: sélectionne dans la liste (sans générer)
|
| 313 |
def pick_example_prompt(example):
|
| 314 |
return example
|
| 315 |
|
| 316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
with gr.Blocks(title="WizzGPTv7 - Text Completion (GGUF - CPU)") as demo:
|
| 318 |
gr.Markdown("## WizzGPTv7 - Text Completion (GGUF - CPU)")
|
| 319 |
|
| 320 |
with gr.Row():
|
| 321 |
prompt_box = gr.Textbox(lines=5, label="Prompt", placeholder="Enter your prompt here...")
|
|
|
|
|
|
|
|
|
|
| 322 |
random_button = gr.Button("🎲 Random Prompt")
|
| 323 |
|
| 324 |
with gr.Row():
|
|
@@ -326,15 +330,11 @@ with gr.Blocks(title="WizzGPTv7 - Text Completion (GGUF - CPU)") as demo:
|
|
| 326 |
num_slider = gr.Slider(minimum=1, maximum=7, step=1, value=1, label="Number of Responses")
|
| 327 |
|
| 328 |
output_box = gr.Textbox(label="Completions", lines=15)
|
| 329 |
-
submit_button = gr.Button("Submit")
|
| 330 |
|
| 331 |
-
#
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
# Random remplissage uniquement
|
| 335 |
random_button.click(fn=pick_random_prompt, outputs=prompt_box)
|
| 336 |
-
|
| 337 |
-
# Remplir via dropdown uniquement
|
| 338 |
example_dropdown.change(fn=pick_example_prompt, inputs=example_dropdown, outputs=prompt_box)
|
|
|
|
| 339 |
|
| 340 |
demo.launch()
|
|
|
|
| 295 |
"A concept art of"
|
| 296 |
]
|
| 297 |
|
| 298 |
+
# Afficher TOUTE la liste dans la dropdown
|
| 299 |
+
prompt_examples = prompt_list
|
| 300 |
|
|
|
|
| 301 |
def generate(prompt, n):
|
| 302 |
return "\n\n---\n\n".join(
|
| 303 |
prompt + llm(prompt, max_tokens=200, stop=["</s>"], echo=False)["choices"][0]["text"]
|
| 304 |
for _ in range(n)
|
| 305 |
)
|
| 306 |
|
|
|
|
| 307 |
def pick_random_prompt():
|
| 308 |
return random.choice(prompt_list)
|
| 309 |
|
|
|
|
| 310 |
def pick_example_prompt(example):
|
| 311 |
return example
|
| 312 |
|
| 313 |
+
def update_button_labels(n):
|
| 314 |
+
suffix = "Prompt" if n == 1 else "Prompts"
|
| 315 |
+
return f"Generate {suffix}", f"🎲 Random {suffix}"
|
| 316 |
+
|
| 317 |
+
# UI Gradio
|
| 318 |
with gr.Blocks(title="WizzGPTv7 - Text Completion (GGUF - CPU)") as demo:
|
| 319 |
gr.Markdown("## WizzGPTv7 - Text Completion (GGUF - CPU)")
|
| 320 |
|
| 321 |
with gr.Row():
|
| 322 |
prompt_box = gr.Textbox(lines=5, label="Prompt", placeholder="Enter your prompt here...")
|
| 323 |
+
|
| 324 |
+
with gr.Row():
|
| 325 |
+
generate_button = gr.Button("Generate Prompt")
|
| 326 |
random_button = gr.Button("🎲 Random Prompt")
|
| 327 |
|
| 328 |
with gr.Row():
|
|
|
|
| 330 |
num_slider = gr.Slider(minimum=1, maximum=7, step=1, value=1, label="Number of Responses")
|
| 331 |
|
| 332 |
output_box = gr.Textbox(label="Completions", lines=15)
|
|
|
|
| 333 |
|
| 334 |
+
# Fonctions reliées
|
| 335 |
+
generate_button.click(generate, inputs=[prompt_box, num_slider], outputs=output_box)
|
|
|
|
|
|
|
| 336 |
random_button.click(fn=pick_random_prompt, outputs=prompt_box)
|
|
|
|
|
|
|
| 337 |
example_dropdown.change(fn=pick_example_prompt, inputs=example_dropdown, outputs=prompt_box)
|
| 338 |
+
num_slider.change(fn=update_button_labels, inputs=num_slider, outputs=[generate_button, random_button])
|
| 339 |
|
| 340 |
demo.launch()
|