File size: 1,137 Bytes
e1429a9
 
 
 
 
6e6c263
 
 
 
 
e1429a9
6e6c263
67c4f81
6e6c263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr

with gr.Blocks(fill_height=True) as demo:
    with gr.Sidebar():
        gr.Markdown("# Inference Provider")
        gr.Markdown(
            "Este Space muestra el modelo Qwen/QwQ-32B, servido por la API hyperbolic. "
            "Inicia sesi贸n con tu cuenta de Hugging Face para usar esta API."
        )
        button = gr.LoginButton("Iniciar sesi贸n")
    
    # Cargamos el modelo usando el token proporcionado por el bot贸n
    model = gr.load("models/microsoft/phi-4", accept_token=button, provider="hyperbolic")
    
    # Definimos la funci贸n que llama a la API del modelo
    def call_inference(prompt: str) -> str:
        respuesta = model(prompt)
        return respuesta

    # Creamos la interfaz para enviar un prompt y mostrar la respuesta
    with gr.Row():
        input_text = gr.Textbox(label="Ingresa tu prompt", placeholder="Escribe aqu铆...")
        output_text = gr.Textbox(label="Respuesta")
    
    # Bot贸n que ejecuta la funci贸n de inferencia
    infer_button = gr.Button("Generar")
    infer_button.click(fn=call_inference, inputs=input_text, outputs=output_text)

demo.launch()