File size: 790 Bytes
1766fcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
from transformers import pipeline

# Load the conversational model
def load_chat_model():
    return pipeline("text-generation", model="microsoft/DialoGPT-medium")

chat_model = load_chat_model()

# Define the chat function
def chat_with_bot(user_input):
    # Generate response from the chatbot model
    response = chat_model(user_input, max_length=100, num_return_sequences=1)
    return response[0]['generated_text']

# Create the Gradio interface
iface = gr.Interface(
    fn=chat_with_bot,
    inputs=gr.inputs.Textbox(label="You:"),
    outputs=gr.outputs.Textbox(label="Bot:"),
    title="English Learning Chatbot",
    description="Talk to the chatbot to practice English.",
    theme="default"
)

# Launch the app
if __name__ == "__main__":
    iface.launch()