bickallen commited on
Commit
5f25aac
·
verified ·
1 Parent(s): 9356372

Create gr_chat.py

Browse files
Files changed (1) hide show
  1. gr_chat.py +22 -0
gr_chat.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import Conversation, pipeline
3
+
4
+ message_list = []
5
+ response_list = []
6
+
7
+ # Initialize the chatbot pipeline
8
+ chatbot = pipeline(model="facebook/blenderbot-400M-distill",
9
+ task="conversational")
10
+
11
+
12
+ def chat_with_bot(message, history):
13
+ conversation = Conversation(
14
+ text=message, past_user_inputs=message_list, generated_responses=response_list)
15
+ conversation = chatbot(conversation)
16
+
17
+ return conversation.generated_responses[-1]
18
+
19
+
20
+ iface = gr.ChatInterface(
21
+ chat_with_bot, title="My Conversational AI", description="A chatbot powered by Hugging Face Transformers!")
22
+ iface.launch()