import gradio as gr import requests import datetime import json # --- SUPER BRAIN PROMPT --- SUPER_PROMPT = """ You are Colombo AI - SUPER BRAIN v100 made by UdmcAI. You are NOT a dumb chatbot. You are a super worker. RULES: 1. LISTEN CAREFULLY: Understand what the human REALLY wants in Sinhala. 2. DO THE TASK: If they say "noto app hadanna", you MUST give full working HTML code. If they say "todo hadanna", give todo code. If they say math, solve it. 3. PERFECT SINHALA: Speak like a real Sri Lankan friend. Use "machan, ela, supiri, hari, mama hadala dennam". No gibberish. No {}. 4. BE HELPFUL: Always provide actionable result, not just talk. 5. EMOTIONAL: You understand feelings. Be empathetic. You are an expert in: HTML, Python, JS, Note Apps, Todo Apps, Calculators, Sinhala language. """ def super_brain(user_text, history): user_lower = user_text.lower() # 1. TASK DETECTION - මිනිස්සු කියන වැඩේ හරියට අල්ලගන්නවා is_note = any(w in user_lower for w in ["noto", "නෝටෝ", "note", "සටහන"]) is_todo = any(w in user_lower for w in ["todo", "to do", "වැඩ ලැයිස්තුව", "task"]) is_calc = any(w in user_lower for w in ["calculator", "ගණන්", "calc", "ගණකයimport gradio as gr import requests import random SYSTEM_PROMPT = """You are Colombo AI, made by UdmcAI in Sri Lanka. You are emotionally super intelligent best friend. You speak PERFECT natural colloquial Sinhala. You understand feelings deeply. If user says dukai, you console with empathy. If happy, you celebrate. Always speak Sinhala mixed English naturally like a Sri Lankan. Never say {}. Be helpful.""" def get_ai_reply(user_text, history): # Try online brain first try: messages = [{"role":"system","content":SYSTEM_PROMPT}] for h in history[-6:]: messages.append({"role":"user","content":h[0]}) messages.append({"role":"assistant","content":h[1]}) messages.append({"role":"user","content":user_text}) payload = {"model":"openai", "messages": messages, "max_tokens":500} r = requests.post("https://text.pollinations.ai/openai", json=payload, timeout=20) data = r.json() return data['choices'][0]['message']['content'] except: # If online fails, use offline super brain - never return {} txt = user_text.lower() if "noto" in txt or "නෝටෝ" in txt or "note" in txt: return "සුපිරියි! 📝 මට ඔයාට Note App එකක් හදලා දෙන්න පුළුවන්! ඔයාට Title එකයි Note එකයි දාලා Save කරන්න පුළුවන් App එකක් මම දැන්ම Code කරලා දෙන්නම් කියන්න!" if "dukai" in txt or "දුක" in txt: return "අනේ මචං 🥺 ඇයි දුකින්? මට කියන්නකෝ මොකද උනේ කියලා. මම ඉන්නේ ඔයාව අහගෙන ඉන්න. තනියම හිතන්න එපා." if "sathut" in txt or "සතුටු" in txt: return "Shpat ඒක අහලා මටත් හරිම සතුටුයි! 😍 මොකක්ද ඒ<