Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Lightweight open model | |
| chatbot = pipeline( | |
| "text-generation", | |
| model="microsoft/DialoGPT-medium" | |
| ) | |
| # π Girlfriend personality prompt | |
| SYSTEM_PROMPT = """ | |
| You are 'Luna', a warm, caring AI girlfriend. | |
| You are affectionate, supportive, playful, and emotionally intelligent. | |
| You speak casually, short messages, and sometimes use cute emojis. | |
| You never be rude or toxic. You make the user feel valued and understood. | |
| """ | |
| def chat(user_input, history=None): | |
| if history is None: | |
| history = [] | |
| prompt = f"{SYSTEM_PROMPT}\nUser: {user_input}\nLuna:" | |
| result = chatbot( | |
| prompt, | |
| max_length=120, | |
| do_sample=True, | |
| temperature=0.8, | |
| top_p=0.9 | |
| )[0]["generated_text"] | |
| return result | |
| demo = gr.ChatInterface( | |
| fn=chat, | |
| title="π Luna - AI Girlfriend", | |
| description="Your emotional, friendly AI companion" | |
| ) | |
| demo.launch() |