import gradio as gr | |
from transformers import pipeline | |
# Cargar el modelo GPT-2 para generaci贸n de texto | |
generator = pipeline('text-generation', model='gpt2') | |
# Funci贸n para manejar el chatbot | |
def chatbot_response(input_text): | |
response = generator(input_text, max_length=50, num_return_sequences=1) | |
return response[0]['generated_text'] | |
# Crear la interfaz del chatbot | |
iface = gr.ChatInterface(fn=chatbot_response, title="Chatbot GPT-2") | |
# Ejecutar la aplicaci贸n | |
iface.launch() | |