Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # BlenderBot-400M | |
| chatbot = pipeline("text2text-generation", model="facebook/blenderbot-400M-distill") | |
| # Chat function | |
| def chat(prompt): | |
| response = chatbot(prompt, max_length=50, do_sample=True, temperature=0.7) | |
| return response[0]["generated_text"] | |
| # create Gradio Web App | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## 🤖 AI Chatbot - Powered by BlenderBot") | |
| prompt_input = gr.Textbox(label="Enter your message") | |
| submit_button = gr.Button("Generate Response") | |
| output_text = gr.Markdown("### AI Response will appear here ⬇️") | |
| submit_button.click(chat, inputs=prompt_input, outputs=output_text) | |
| # lunch | |
| demo.launch() | |