from transformers import pipeline | |
import gradio as gr | |
# Chatbot pipeline using Hugging Face's conversational model | |
chatbot = pipeline('conversational') | |
# Function to handle chatbot conversations | |
def chat(input_text): | |
response = chatbot(input_text) | |
return response[0]['generated_text'] | |
# Gradio interface for the chatbot | |
with gr.Blocks() as chatbot_app: | |
user_input = gr.Textbox(label="Ask me anything (e.g., What are today's specials?)") | |
chat_button = gr.Button("Send") | |
chatbot_output = gr.Textbox(label="Chatbot Response") | |
chat_button.click(fn=chat, inputs=user_input, outputs=chatbot_output) | |
chatbot_app.launch() | |