Update app.py
Browse files
app.py
CHANGED
|
@@ -171,7 +171,20 @@ def identity_manager (frase, persona):
|
|
| 171 |
# pero con Gradio Client es suficiente para engine/local.
|
| 172 |
|
| 173 |
# ------------------- UI -------------------
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
gr.Markdown("## Salamandra-7B-Instruct · ZeroGPU\nTexto → respuesta instruccional.")
|
| 176 |
with gr.Row():
|
| 177 |
with gr.Column(scale=1):
|
|
@@ -185,12 +198,13 @@ with gr.Blocks(title="Salamandra 7B Instruct · ZeroGPU") as demo:
|
|
| 185 |
out = gr.Textbox(label="Respuesta", lines=18)
|
| 186 |
|
| 187 |
btn.click(generate_advanced, [in_prompt, in_system, max_new, temp, top_p], out, api_name="generate", concurrency_limit=1)
|
| 188 |
-
|
| 189 |
# Endpoint minimalista compatible con el ENGINE (/predict: solo prompt)
|
| 190 |
in_prompt_engine = gr.Textbox(label="Prompt (ENGINE)", value="Di hola en una frase.")
|
| 191 |
out_engine = gr.Textbox(label="Respuesta (ENGINE)")
|
| 192 |
gr.Button("Probar /predict").click(predict_for_engine, [in_prompt_engine], out_engine, api_name="predict", concurrency_limit=1)
|
| 193 |
-
|
|
|
|
| 194 |
gr.Markdown('<h2 style="text-align:center">Sortida del model Salamandra a partir d’una petició</h2>')
|
| 195 |
with gr.Row():
|
| 196 |
prompt = gr.Textbox(label="prompt", lines=10)
|
|
@@ -200,15 +214,17 @@ with gr.Blocks(title="Salamandra 7B Instruct · ZeroGPU") as demo:
|
|
| 200 |
out2 = gr.JSON(label="Salida")
|
| 201 |
|
| 202 |
btn2.click(salamandra_chat_endpoint, [prompt], out2, api_name="generate_out_from_prompt", concurrency_limit=1)
|
| 203 |
-
|
|
|
|
| 204 |
gr.Markdown('<h2 style="text-align:center">Resumir frases</h2>')
|
| 205 |
with gr.Row():
|
| 206 |
with gr.Column(scale=1):
|
| 207 |
frase = gr.Textbox(label="Frase a resumir", value="", lines=3)
|
| 208 |
num_paraules = gr.Textbox(label="Nombre de paraules del resum", value="4")
|
| 209 |
-
btn_resumir = gr.Button("Resumir", variant="primary")
|
| 210 |
with gr.Column(scale=1):
|
| 211 |
out_resumir = gr.Textbox(label="Resposta", lines=18)
|
|
|
|
|
|
|
| 212 |
|
| 213 |
btn_resumir.click(
|
| 214 |
resumir_frases,
|
|
@@ -217,16 +233,18 @@ with gr.Blocks(title="Salamandra 7B Instruct · ZeroGPU") as demo:
|
|
| 217 |
api_name="resumir",
|
| 218 |
concurrency_limit=1
|
| 219 |
)
|
| 220 |
-
|
|
|
|
| 221 |
gr.Markdown('<h2 style="text-align:center">Inclusió d’identitats</h2>')
|
| 222 |
with gr.Row():
|
| 223 |
with gr.Column(scale=1):
|
| 224 |
frase = gr.Textbox(label="Frase a modificar", value="", lines=3)
|
| 225 |
persona = gr.Textbox(label="Persones reconegudes", value='"Mireia Martí": 4, "Xavier Busquets": 5')
|
| 226 |
-
btn_modificar = gr.Button("Modificar frase", variant="primary")
|
| 227 |
with gr.Column(scale=1):
|
| 228 |
out_modificat = gr.Textbox(label="Resposta", lines=18)
|
| 229 |
-
|
|
|
|
|
|
|
| 230 |
btn_modificar.click(
|
| 231 |
identity_manager,
|
| 232 |
inputs=[frase, persona],
|
|
|
|
| 171 |
# pero con Gradio Client es suficiente para engine/local.
|
| 172 |
|
| 173 |
# ------------------- UI -------------------
|
| 174 |
+
custom_css = """
|
| 175 |
+
h2 {
|
| 176 |
+
background: #e3e4e6 !important;
|
| 177 |
+
padding: 14px 22px !important;
|
| 178 |
+
border-radius: 14px !important;
|
| 179 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important;
|
| 180 |
+
display: block !important; /* ocupa tot l'ample */
|
| 181 |
+
width: 100% !important; /* assegura 100% */
|
| 182 |
+
margin: 20px auto !important;
|
| 183 |
+
text-align:center;
|
| 184 |
+
}
|
| 185 |
+
"""
|
| 186 |
+
|
| 187 |
+
with gr.Blocks(title="Salamandra 7B Instruct · ZeroGPU",css=custom_css,theme=gr.themes.Soft()) as demo:
|
| 188 |
gr.Markdown("## Salamandra-7B-Instruct · ZeroGPU\nTexto → respuesta instruccional.")
|
| 189 |
with gr.Row():
|
| 190 |
with gr.Column(scale=1):
|
|
|
|
| 198 |
out = gr.Textbox(label="Respuesta", lines=18)
|
| 199 |
|
| 200 |
btn.click(generate_advanced, [in_prompt, in_system, max_new, temp, top_p], out, api_name="generate", concurrency_limit=1)
|
| 201 |
+
gr.Markdown("---")
|
| 202 |
# Endpoint minimalista compatible con el ENGINE (/predict: solo prompt)
|
| 203 |
in_prompt_engine = gr.Textbox(label="Prompt (ENGINE)", value="Di hola en una frase.")
|
| 204 |
out_engine = gr.Textbox(label="Respuesta (ENGINE)")
|
| 205 |
gr.Button("Probar /predict").click(predict_for_engine, [in_prompt_engine], out_engine, api_name="predict", concurrency_limit=1)
|
| 206 |
+
gr.Markdown("---")
|
| 207 |
+
|
| 208 |
gr.Markdown('<h2 style="text-align:center">Sortida del model Salamandra a partir d’una petició</h2>')
|
| 209 |
with gr.Row():
|
| 210 |
prompt = gr.Textbox(label="prompt", lines=10)
|
|
|
|
| 214 |
out2 = gr.JSON(label="Salida")
|
| 215 |
|
| 216 |
btn2.click(salamandra_chat_endpoint, [prompt], out2, api_name="generate_out_from_prompt", concurrency_limit=1)
|
| 217 |
+
gr.Markdown("---")
|
| 218 |
+
|
| 219 |
gr.Markdown('<h2 style="text-align:center">Resumir frases</h2>')
|
| 220 |
with gr.Row():
|
| 221 |
with gr.Column(scale=1):
|
| 222 |
frase = gr.Textbox(label="Frase a resumir", value="", lines=3)
|
| 223 |
num_paraules = gr.Textbox(label="Nombre de paraules del resum", value="4")
|
|
|
|
| 224 |
with gr.Column(scale=1):
|
| 225 |
out_resumir = gr.Textbox(label="Resposta", lines=18)
|
| 226 |
+
with gr.Row():
|
| 227 |
+
btn_resumir = gr.Button("Resumir", variant="primary")
|
| 228 |
|
| 229 |
btn_resumir.click(
|
| 230 |
resumir_frases,
|
|
|
|
| 233 |
api_name="resumir",
|
| 234 |
concurrency_limit=1
|
| 235 |
)
|
| 236 |
+
gr.Markdown("---")
|
| 237 |
+
|
| 238 |
gr.Markdown('<h2 style="text-align:center">Inclusió d’identitats</h2>')
|
| 239 |
with gr.Row():
|
| 240 |
with gr.Column(scale=1):
|
| 241 |
frase = gr.Textbox(label="Frase a modificar", value="", lines=3)
|
| 242 |
persona = gr.Textbox(label="Persones reconegudes", value='"Mireia Martí": 4, "Xavier Busquets": 5')
|
|
|
|
| 243 |
with gr.Column(scale=1):
|
| 244 |
out_modificat = gr.Textbox(label="Resposta", lines=18)
|
| 245 |
+
with gr.Row():
|
| 246 |
+
btn_modificar = gr.Button("Modificar frase", variant="primary")
|
| 247 |
+
|
| 248 |
btn_modificar.click(
|
| 249 |
identity_manager,
|
| 250 |
inputs=[frase, persona],
|