Spaces:
Runtime error
Runtime error
File size: 1,383 Bytes
38fb619 |
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 31 32 33 34 35 36 37 38 39 |
import gradio as gr
from transformers import pipeline, Conversation
# Modelo de Hugging Face para conversaci贸n
model_name = "microsoft/DialoGPT-large"
conversation_model = pipeline("conversational", model=model_name)
# Historial de la conversaci贸n, se mantendr谩 dentro del contexto de la aplicaci贸n
conversation = Conversation()
# Funci贸n para procesar la entrada del usuario y generar la respuesta
def chatbot_response(user_input):
# Agregar la respuesta del usuario al historial de la conversaci贸n
conversation.add_user_input(user_input)
# Generar la respuesta del bot
bot_response = conversation_model(user_input, conversation=conversation)["generated_text"]
# Agregar la respuesta del bot al historial de la conversaci贸n
conversation.add_system_output(bot_response)
# Retornar la respuesta del bot para mostrarla en la interfaz
return bot_response
# Ejecuci贸n de la aplicaci贸n
if __name__ == "__main__":
# Interfaz de Gradio para la aplicaci贸n web
iface = gr.Interface(
fn=chatbot_response,
inputs=gr.Textbox(lines=2, placeholder="Escribe tu mensaje aqu铆..."),
outputs=gr.Textbox(lines=2, placeholder="Respuesta del bot..."),
title="Entrevista de Programaci贸n - ChatBot",
theme="compact",
live=True
)
# Lanzar la interfaz de Gradio
iface.launch()
|