File size: 648 Bytes
5f25aac
e1cd7ef
5f25aac
e1cd7ef
 
5f25aac
e1cd7ef
 
 
5f25aac
 
e1cd7ef
 
 
 
5f25aac
e1cd7ef
5f25aac
 
e1cd7ef
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from transformers import Conversation, pipeline

message_list = []
response_list = []

# Initialize the chatbot pipeline
chatbot = pipeline(model="facebook/blenderbot-400M-distill",
                   task="conversational")


def chat_with_bot(message, history):
    conversation = Conversation(
        text=message, past_user_inputs=message_list, generated_responses=response_list)
    conversation = chatbot(conversation)

    return conversation.generated_responses[-1]


iface = gr.ChatInterface(
    chat_with_bot, title="My Conversational AI", description="A chatbot powered by Hugging Face Transformers!")
iface.launch()