Spaces:
Runtime error
Runtime error
Manish
commited on
Commit
·
26257ef
1
Parent(s):
6efa9b3
"Feat: Add python code for AI_CHATBOT"
Browse filesUse pipeline class of transfomer library from hugging face to access Facebook's distillBert model which generates conversation. Use Gradio for UI interface.
app.py
CHANGED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline, Conversation
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
Chatbot = pipeline(task = "conversational", model ="facebook/blenderbot-400M-distill")
|
5 |
+
#text, get it from user from gradio
|
6 |
+
|
7 |
+
message_list = []
|
8 |
+
response_list = []
|
9 |
+
|
10 |
+
def mini_chatbot(message, history):
|
11 |
+
conversation = Conversation(text = message,
|
12 |
+
past_user_inputs = message_list,
|
13 |
+
generated_responses = response_list)
|
14 |
+
response = Chatbot(conversation)
|
15 |
+
return response.generated_responses[-1]
|
16 |
+
demo_chatbot = gr.ChatInterface(mini_chatbot, title="AI Chatbot" , description="Enter text to CHAT with AI")
|
17 |
+
demo_chatbot.launch()
|