akazmi commited on
Commit
ef9aa44
·
verified ·
1 Parent(s): 3a912e4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the conversational model
5
+ def load_model():
6
+ return pipeline("conversational", model="microsoft/DialoGPT-medium")
7
+
8
+ chatbot = load_model()
9
+
10
+ # Define a function for the chatbot
11
+ def respond(message):
12
+ response = chatbot(message)
13
+ return response.generated_responses[0]
14
+
15
+ # Set up the Gradio interface
16
+ iface = gr.Interface(
17
+ fn=respond,
18
+ inputs=gr.inputs.Textbox(placeholder="Type your message here..."),
19
+ outputs="text",
20
+ title="Chatbot with DialoGPT",
21
+ description="Ask me anything!"
22
+ )
23
+
24
+ # Launch the interface
25
+ if __name__ == "__main__":
26
+ iface.launch()