File size: 774 Bytes
4084a00
b12fc95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4084a00
 
b12fc95
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

# Cargamos el modelo de Hugging Face (es un modelo de espa帽ol)
modelo = pipeline("text-generation", model="dccuchile/bert-base-spanish-wwm-cased")

# Definimos la funci贸n que genera la respuesta
def chatbot(pregunta):
    respuesta = modelo(pregunta, max_length=50, num_return_sequences=1)[0]['generated_text']
    return respuesta

# Configuraci贸n de la interfaz de usuario de Gradio
interfaz = gr.Interface(
    fn=chatbot,  # Funci贸n que llama al modelo para generar respuestas
    inputs="text",  # Entrada de texto
    outputs="text",  # Salida de texto
    title="Chatbot en Espa帽ol",
    description="Escribe una pregunta y el chatbot responder谩 en espa帽ol."
)

# Ejecutamos la interfaz
interfaz.launch()