Spaces:
Sleeping
Sleeping
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()
|