Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from google import genai | |
| def summarize(entrada, system_prompt): | |
| texto = str(system_prompt) + "\n" + entrada | |
| client = genai.Client(api_key="YOUR_API_KEY") | |
| output = client.models.generate_content(model="gemini-2.0-flash", contents=texto) | |
| return output.text | |
| def save_system_prompt(prompt): | |
| return f"System prompt guardado: {prompt}" | |
| with gr.Blocks() as demo: | |
| with gr.Tabs(): | |
| # Tab para ejecución | |
| with gr.Tab("Ejecución"): | |
| with gr.Row(): | |
| with gr.Column(): | |
| user_input = gr.Textbox(label="Escribe una pregunta") | |
| button = gr.Button("Enviar pregunta") | |
| with gr.Column(): | |
| output = gr.Markdown() | |
| button.click(summarize, inputs=[user_input, gr.State()], outputs=output) | |
| # Tab para configuración | |
| with gr.Tab("Configuración"): | |
| system_prompt_input = gr.Textbox(label="Define el system prompt", lines=3) | |
| save_button = gr.Button("Guardar configuración") | |
| saved_prompt_output = gr.Markdown() | |
| save_button.click(save_system_prompt, inputs=system_prompt_input, outputs=saved_prompt_output) | |
| demo.launch(show_error=True) | |