Hira99 commited on
Commit
1766fcc
1 Parent(s): 3198a92

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the conversational model
5
+ def load_chat_model():
6
+ return pipeline("text-generation", model="microsoft/DialoGPT-medium")
7
+
8
+ chat_model = load_chat_model()
9
+
10
+ # Define the chat function
11
+ def chat_with_bot(user_input):
12
+ # Generate response from the chatbot model
13
+ response = chat_model(user_input, max_length=100, num_return_sequences=1)
14
+ return response[0]['generated_text']
15
+
16
+ # Create the Gradio interface
17
+ iface = gr.Interface(
18
+ fn=chat_with_bot,
19
+ inputs=gr.inputs.Textbox(label="You:"),
20
+ outputs=gr.outputs.Textbox(label="Bot:"),
21
+ title="English Learning Chatbot",
22
+ description="Talk to the chatbot to practice English.",
23
+ theme="default"
24
+ )
25
+
26
+ # Launch the app
27
+ if __name__ == "__main__":
28
+ iface.launch()