KRayRay commited on
Commit
5a13686
·
verified ·
1 Parent(s): 905e21c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # BlenderBot-400M
5
+ chatbot = pipeline("text2text-generation", model="facebook/blenderbot-400M-distill")
6
+
7
+ # Chat function
8
+ def chat(prompt):
9
+ response = chatbot(prompt, max_length=50, do_sample=True, temperature=0.7)
10
+ return response[0]["generated_text"]
11
+
12
+ # create Gradio Web App
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("## 🤖 AI Chatbot - Powered by BlenderBot")
15
+ prompt_input = gr.Textbox(label="Enter your message")
16
+ submit_button = gr.Button("Generate Response")
17
+ output_text = gr.Markdown("### AI Response will appear here ⬇️")
18
+
19
+ submit_button.click(chat, inputs=prompt_input, outputs=output_text)
20
+
21
+ # lunch
22
+ demo.launch()