Spaces:
Sleeping
Sleeping
| # import gradio as gr | |
| # def greet(name): | |
| # return "Hello " + name + "!!" | |
| # iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| # iface.launch() | |
| import gradio as gr | |
| import torch | |
| from transformers import Conversation, pipeline | |
| model_name = "facebook/blenderbot-400M-distill" | |
| chatbot = pipeline("conversational", model=model_name) | |
| # Define the chatbot function | |
| def generate_response(input_text): | |
| conversation = Conversation() | |
| conversation.add_user_input(input_text) | |
| response = chatbot(conversation) | |
| return response | |
| # .choices[0]['message']['content'] | |
| # Set up the Gradio interface | |
| iface = gr.Interface( | |
| fn=generate_response, | |
| inputs=gr.inputs.Textbox(placeholder="Enter your message..."), | |
| outputs="text", | |
| title="Conversational Chatbot", | |
| description="An AI-powered chatbot that engages in conversation.", | |
| theme="default" | |
| ) | |
| # Launch the Gradio interface | |
| iface.launch() |