File size: 648 Bytes
eeff931
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from transformers import pipeline

# Load the conversational model
chatbot = pipeline("conversational", model="microsoft/DialoGPT-medium")

def respond(message):
    # Construct a friendly prompt for Aya
    prompt = f"You are Aya, a friendly AI that speaks in simple, clear language. You always respond positively and encouragingly. Here’s what the user says: {message} \nYour response:"
    
    # Generate response
    response = chatbot(prompt)
    generated_text = response[-1]['generated_text']
    
    # Optionally add emojis and excitement
    if "!" not in generated_text:
        generated_text += " :3"
    
    return generated_text