Ram7379 commited on
Commit
043d0b7
·
verified ·
1 Parent(s): 0fa5c23

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load lightweight dialogue model
5
+ chatbot = pipeline(
6
+ "text-generation",
7
+ model="microsoft/DialoGPT-small"
8
+ )
9
+
10
+ # Function
11
+ def reply(message):
12
+ if not message.strip():
13
+ return "Please enter a message."
14
+
15
+ result = chatbot(
16
+ message,
17
+ max_new_tokens=60,
18
+ do_sample=True,
19
+ temperature=0.7,
20
+ pad_token_id=50256
21
+ )
22
+
23
+ return result[0]["generated_text"]
24
+
25
+ # Gradio UI
26
+ demo = gr.Interface(
27
+ fn=reply,
28
+ inputs=gr.Textbox(
29
+ lines=2,
30
+ label="Your Message",
31
+ placeholder="Say hello..."
32
+ ),
33
+ outputs=gr.Textbox(
34
+ lines=4,
35
+ label="Bot Reply"
36
+ ),
37
+ title="💬 Dialogue System",
38
+ description="Conversational AI using DialoGPT model.",
39
+ theme=gr.themes.Soft()
40
+ )
41
+
42
+ demo.launch(server_name="0.0.0.0", server_port=7860)