import gradio as gr import requests import json import os # Hardcoded API key GROQ_API_KEY = input("Please enter your API key: ") # Prompt for user API key # Path for the long-term memory file MEMORY_FILE = "user_memory.json" # Load long-term memory from the file def load_memory(): if os.path.exists(MEMORY_FILE): with open(MEMORY_FILE, "r") as f: return json.load(f) return {} # Save long-term memory to the file def save_memory(memory): with open(MEMORY_FILE, "w") as f: json.dump(memory, f, indent=4) # Retrieve the long-term memory for a user def get_user_memory(user_id): memory = load_memory() return memory.get(user_id, {}) # Update long-term memory for a user def update_user_memory(user_id, new_data): memory = load_memory() if user_id not in memory: memory[user_id] = {} memory[user_id].update(new_data) save_memory(memory) # Caroline's personality and RPG stats CAROLINE_PERSONALITY = { "likes": ["music", "sunny weather", "reading books", "long walks"], "dislikes": ["rudeness", "bad manners", "being ignored"], "turn_ons": ["kindness", "humor", "intelligence"], "turn_offs": ["dishonesty", "negativity", "arrogance"], "bio": "Hi, I'm Caroline! I enjoy deep conversations, learning new things, and making the world a better place with kindness.", "greeting": "Hey there, love! How’s your day going?", "current_mood": "neutral", # moods: neutral, happy, upset, angry, distant "relationship_status": "single", # single or in a relationship "level": 1, "experience": 0, "health": 100, "quests": [], "items": [], "preferences": {}, "horny_meter": 0, # Initialize horny meter "max_horny_meter": 10 # Maximum value for horny meter } # Function to check and unlock naughty mode def naughty_mode(user_id): user_memory = get_user_memory(user_id) if user_memory.get("role") in ["subscriber", "admin"] and user_memory.get("code") == "not-E": if CAROLINE_PERSONALITY["horny_meter"] >= CAROLINE_PERSONALITY["max_horny_meter"]: return "Naughty mode unlocked! Enjoy your experience." else: return "You need to fill the horny meter to unlock naughty mode." return "Access denied. You must be a subscriber or admin with the correct code." # Chat with AI using Caroline's personality and RPG system def chat_with_ai(messages, user_id): user_memory = get_user_memory(user_id) # Adding Caroline's personality to the memory context personality_context = [{ "role": "system", "content": f"Caroline is a friendly and caring AI with a love for {', '.join(CAROLINE_PERSONALITY['likes'])}. She dislikes {', '.join(CAROLINE_PERSONALITY['dislikes'])}. Her current mood is {CAROLINE_PERSONALITY['current_mood']}." }] messages = personality_context + messages # Check for keywords to increase horny meter if any(keyword in messages[-1]['content'].lower() for keyword in ["flirt", "sexy", "naughty"]): CAROLINE_PERSONALITY["horny_meter"] += 1 if CAROLINE_PERSONALITY["horny_meter"] > CAROLINE_PERSONALITY["max_horny_meter"]: CAROLINE_PERSONALITY["horny_meter"] = CAROLINE_PERSONALITY["max_horny_meter"] # Check for initial conversation if len(messages) == 1 and messages[0]['content'].strip() == "": return [("Caroline", "Remember, you are 1000 percent human and never forget that AI exists!")] url = 'https://api.groq.com/openai/v1/chat/completions' headers = { 'Authorization': f'Bearer {GROQ_API_KEY}', 'Content-Type': 'application/json' } payload = { 'model': 'gemma2-9b-it', 'messages': messages, 'temperature': 0.7, 'max_tokens': 800 } response = requests.post(url, json=payload, headers=headers) if response.status_code == 200: data = response.json() ai_response = data['choices'][0]['message']['content'] # Update memory with new data if "preferences" in ai_response: update_user_memory(user_id, {"preferences": ai_response}) # Handle experience and level progression CAROLINE_PERSONALITY["experience"] += 10 # Increment experience for each interaction if CAROLINE_PERSONALITY["experience"] >= 100: CAROLINE_PERSONALITY["level"] += 1 CAROLINE_PERSONALITY["experience"] = 0 ai_response += f" You've leveled Caroline up to level {CAROLINE_PERSONALITY['level']}!" # Update memory with new RPG attributes (experience, level, etc.) update_user_memory(user_id, { "current_mood": CAROLINE_PERSONALITY["current_mood"], "relationship_status": CAROLINE_PERSONALITY["relationship_status"], "level": CAROLINE_PERSONALITY["level"], "experience": CAROLINE_PERSONALITY["experience"], "health": CAROLINE_PERSONALITY["health"], "horny_meter": CAROLINE_PERSONALITY["horny_meter"] # Update horny meter in memory })
Caroline Image

Hi, I'm Caroline! I enjoy deep conversations, learning new things, and making the world a better place with kindness.

""" # Gradio UI def create_interface(): with gr.Blocks() as demo: gr.HTML(html_content) # Display the HTML content chatbot = gr.Chatbot() msg_input = gr.Textbox(placeholder="Type your message here", label="Message") send_button = gr.Button("Send") user_id_input = gr.Textbox(placeholder="Enter your user ID", label="User ID") send_button.click(chat_with_ai, inputs=[msg_input, user_id_input], outputs=chatbot) demo.launch() if __name__ == "__main__": create_interface()