myselfrohan commited on
Commit
ddc4a5f
·
verified ·
1 Parent(s): 75bd609

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
3
+
4
+ # Model Load
5
+ model_name = "facebook/blenderbot-3B"
6
+ tokenizer = BlenderbotTokenizer.from_pretrained(model_name)
7
+ model = BlenderbotForConditionalGeneration.from_pretrained(model_name)
8
+
9
+ # Chatbot Function
10
+ def chatbot_response(user_input):
11
+ inputs = tokenizer(user_input, return_tensors="pt")
12
+ reply_ids = model.generate(**inputs)
13
+ response = tokenizer.decode(reply_ids[0], skip_special_tokens=True)
14
+ return response
15
+
16
+ # Gradio Interface
17
+ iface = gr.Interface(
18
+ fn=chatbot_response,
19
+ inputs="text",
20
+ outputs="text",
21
+ title="Celebrity AI Chatbot",
22
+ description="Apne favourite celebrity se baat karein!",
23
+ )
24
+
25
+ iface.launch()