Update app.py
Browse files12345678910112 unmodified lines1415161718192021222324252612 unmodified lines394041424344454647482 unmodified lines5152535455565716 unmodified lines747576777879801 unmodified line828384858687887 unmodified lines9697989910010110215 unmodified lines1181191201211221231243 unmodified lines12812913013113213313413513613713813914014114214314414514652 unmodified lines19920020120220320420510 unmodified lines2162172182192202212225 unmodified lines2282292302312322332345 unmodified lines2402412422432442452462472482492502512522532542552562572582592602612622632642 unmodified lines2672682692702712722732742752762772782792802812822832842852862872882892902919 unmodified lines3013023033043053063077 unmodified lines3153163173183193203213223233243253263273283 unmodified lines3323333343353363373383 unmodified lines3423433443453463473483493503513523533543553563573581 unmodified line3603613623633643653663673683693703716 unmodified lines3783793803813823833844 unmodified lines38939039139239339439514 unmodified lines4104114124134144154164174184194204214224234244254 unmodified lines430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477import osimport ioimport base64import reimport urllib.parsefrom flask import Flask, render_template_string, request, jsonifyfrom huggingface_hub import InferenceClientfrom groq import Groqapp = Flask(__name__)2 unmodified linesGROQ_API_KEY = os.getenv("GROQ_API_KEY")client_hf = InferenceClient(api_key=HF_TOKEN) if HF_TOKEN else Noneclient_groq = Groq(api_key=GROQ_API_KEY)# ==========================================# FRONTEND (AĞ-QARA-BOZ & CINEMATIC BLUR)# ==========================================HTML_TEMPLATE = """<!DOCTYPE html><html lang="az"><head><meta charset="UTF-8">12 unmodified lines--exypos-grad: linear-gradient(135deg, #ffffff, #555555);--bubble-bot-grad: linear-gradient(135deg, #111111, #222222);}* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }body { background-color: var(--bg-dark); color: var(--text-main); height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }/* --- ARXA PLAN OBYEKTLƏRİ (Tüstü/Boz hərəkət) --- */.ambient-bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: #050505; }.orb { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.3; will-change: transform; }2 unmodified lines@keyframes float1 { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(25vw, 35vh) scale(1.1); } }@keyframes float2 { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(-35vw, -25vh) scale(1.2); } }/* --- YENİ CINEMATIC BLUR GİRİŞ (SPLASH) ANİMASİYASI --- */#splash {position: fixed; inset: 0;16 unmodified lines@keyframes cinematicReveal { 100% { opacity: 1; filter: blur(0); transform: scale(1); } }@keyframes subReveal { 100% { opacity: 0.6; filter: blur(0); transform: translateY(0); } }/* --- ÜST PANEL VƏ GOOGLE GİRİŞ --- */.top-bar { position: fixed; top: 0; left: 0; width: 100%; height: 70px; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; z-index: 1000; pointer-events: none; }.menu-btn { pointer-events: auto; background: rgba(255,255,255,0.03); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.08); width: 45px; height: 45px; border-radius: 12px; color: var(--color-white); display: flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; transition: 0.4s; z-index: 2500; }1 unmodified line.login-btn { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.05); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1); padding: 8px 18px; border-radius: 30px; color: var(--color-white); cursor: pointer; font-weight: 500; transition: 0.3s; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }.login-btn:hover { background: rgba(255,255,255,0.15); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(255,255,255,0.1); }.login-btn img { width: 20px; height: 20px; filter: grayscale(100%) brightness(150%); }/* --- SOL SİDEBAR --- */.sidebar { position: fixed; top: 0; left: -320px; width: 300px; height: 100%; background: rgba(10, 10, 10, 0.85); backdrop-filter: blur(35px); border-right: 1px solid rgba(255,255,255,0.05); display: flex; flex-direction: column; padding: 90px 20px 20px 20px; z-index: 2000; transition: left 0.5s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: 20px 0 50px rgba(0,0,0,0.8); }.sidebar.open { left: 0; }7 unmodified lines.history-item { padding: 14px 16px; border-radius: 12px; margin-bottom: 8px; cursor: pointer; color: var(--text-muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(255,255,255,0.02); transition: 0.3s; border: 1px solid transparent; }.history-item:hover { background: rgba(255,255,255,0.08); color: var(--color-white); }.history-item.active { background: rgba(255, 255, 255, 0.1); border-left: 3px solid var(--color-white); color: var(--color-white); }/* --- LIQUID GLASS CHAT ZONASI --- */.chat-area { flex: 1; display: flex; flex-direction: column; padding-top: 80px; position: relative; z-index: 10; align-items: center; }.glass-container { width: 98%; max-width: 1400px; height: calc(100vh - 180px); background: radial-gradient(circle at top left, rgba(255,255,255,0.04), rgba(0,0,0,0.4)); backdrop-filter: blur(40px) saturate(120%); -webkit-backdrop-filter: blur(40px) saturate(120%); border: 1px solid rgba(255, 255, 255, 0.05); border-top: 1px solid rgba(255, 255, 255, 0.1); border-left: 1px solid rgba(255, 255, 255, 0.1); border-radius: 35px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 60px rgba(0,0,0,0.8), inset 0 0 20px rgba(255,255,255,0.01); }15 unmodified lines.typing-cursor::after { content: '▌'; animation: blink 1s step-end infinite; color: var(--color-white); margin-left: 6px; opacity: 0.8; }@keyframes blink { 50% { opacity: 0; } }/* --- İNPUT ZONASI & PLUS MENU --- */.input-zone { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); width: 90%; max-width: 1000px; z-index: 100; }3 unmodified lines.mode-btn { background: transparent; color: var(--text-muted); border: none; padding: 12px 20px; border-radius: 12px; cursor: pointer; text-align: left; font-size: 14px; transition: 0.2s; display: flex; align-items: center; gap: 12px; font-weight: 500; }.mode-btn:hover { background: rgba(255,255,255,0.05); color: var(--color-white); }.mode-btn.active { background: rgba(255,255,255,0.1); color: var(--color-white); border-left: 3px solid var(--color-white); }.input-box { display: flex; align-items: center; background: rgba(15, 15, 15, 0.85); backdrop-filter: blur(25px); border: 1px solid rgba(255,255,255,0.15); border-radius: 35px; padding: 12px 18px 12px 15px; box-shadow: 0 20px 50px rgba(0,0,0,0.8); transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1); }.input-box:focus-within { border-color: rgba(255, 255, 255, 0.5); box-shadow: 0 20px 60px rgba(255, 255, 255, 0.1); transform: translateY(-3px); }.plus-btn { background: transparent; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; padding: 0 15px; transition: 0.3s; display: flex; align-items: center; justify-content: center; height: 100%; }.plus-btn:hover { color: var(--color-white); transform: rotate(90deg); }.input-box input { flex: 1; background: transparent; border: none; color: var(--color-white); font-size: 16px; outline: none; padding: 10px 0; font-weight: 300; letter-spacing: 0.5px; }.input-box input::placeholder { color: rgba(255,255,255,0.3); transition: 0.3s; }.send-btn { width: 48px; height: 48px; border-radius: 50%; border: none; background: var(--color-white); color: black; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.4s; box-shadow: 0 5px 15px rgba(255,255,255,0.1); }.send-btn:hover { transform: scale(1.1) rotate(15deg); box-shadow: 0 8px 25px rgba(255,255,255,0.3); background: #e0e0e0; }/* Limit Modalı */#limit-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(20px); z-index: 3000; display: none; align-items: center; justify-content: center; opacity: 0; transition: 0.6s; }.modal-content { background: rgba(20,20,20,0.95); border: 1px solid rgba(255,255,255,0.1); padding: 50px 40px; border-radius: 25px; text-align: center; max-width: 420px; box-shadow: 0 30px 70px rgba(0,0,0,0.8); }52 unmodified lines<i class="fa-solid fa-fingerprint" style="color: #b0b0b0;"></i> ExyposGReco (EGR)</button></div><div class="input-box"><button class="plus-btn" onclick="toggleModeMenu()"><i class="fa-solid fa-plus"></i></button><input type="text" id="user-input" placeholder="Exypos-a yaz və ya /sekil [mətn]..." autocomplete="off">10 unmodified lines</button></div></div><script>const DB_NAME = 'EXYPOS_ULTRA_MAX_DB';let chats = JSON.parse(localStorage.getItem(DB_NAME)) || {};5 unmodified linesconst chatBox = document.getElementById('chat-box');const inputField = document.getElementById('user-input');window.onload = () => {setTimeout(() => {document.getElementById('splash').style.opacity = '0';5 unmodified lineselse loadChat(activeChatId);renderHistory();};// Rejim Menyusu Funksiyalarıfunction toggleModeMenu() {document.getElementById('mode-menu').classList.toggle('active');}function setAiMode(mode) {currentAiMode = mode;document.querySelectorAll('.mode-btn').forEach(b => b.classList.remove('active'));event.currentTarget.classList.add('active');toggleModeMenu();if(mode === 'ExyposGReco') {inputField.placeholder = "EGR Scanner: Link və ya analiz mətni at...";} else {inputField.placeholder = "Exypos-a yaz və ya /sekil [mətn]...";}}// Menyunu kənara basanda bağlamaq üçündocument.addEventListener('click', function(event) {const menu = document.getElementById('mode-menu');2 unmodified linesmenu.classList.remove('active');}});function toggleSidebar() {document.getElementById('sidebar').classList.toggle('open');document.getElementById('sb-overlay').classList.toggle('open');}function saveDB() {localStorage.setItem(DB_NAME, JSON.stringify(chats));localStorage.setItem('EXYPOS_ACTIVE_MAX', activeChatId);renderHistory();}function createNewChat() {const id = 'chat_' + Date.now();chats[id] = { title: "Yeni Söhbət", messages: [] };activeChatId = id; saveDB(); loadChat(id);if(window.innerWidth <= 768) toggleSidebar();}function loadChat(id) {activeChatId = id; saveDB(); chatBox.innerHTML = '';9 unmodified lineschats[id].messages.forEach(msg => appendMessageUI(msg.sender, msg.content, false, msg.isHTML));}}function renderHistory() {const historyList = document.getElementById('history-list');historyList.innerHTML = '';7 unmodified lineshistoryList.appendChild(div);});}function checkLoginState() {if (isLoggedIn) {document.getElementById('btn-login').innerHTML = `<i class="fa-solid fa-user-check" style="color:#fff;"></i> Tunar (Aktiv)`;document.getElementById('limit-modal').style.display = 'none';}}function simulateGoogleLogin() {document.getElementById('login-text').innerText = "Bağlanır...";setTimeout(() => {3 unmodified linessetTimeout(() => document.getElementById('limit-modal').style.display = 'none', 600);}, 1200);}async function sendMessage() {const text = inputField.value.trim();if (!text) return;3 unmodified linesmodal.style.display = 'flex'; setTimeout(() => modal.style.opacity = '1', 50);return;}if (chats[activeChatId].messages.length === 0) {chats[activeChatId].title = text.substring(0, 25) + "...";chatBox.innerHTML = '';}appendMessageUI('user', text, true);inputField.value = '';if(!isLoggedIn) { msgCount++; localStorage.setItem('EXYPOS_MSG_COUNT', msgCount.toString()); }const loadingId = 'load_' + Date.now();const loadDiv = document.createElement('div');loadDiv.className = 'message msg-bot';1 unmodified lineloadDiv.innerHTML = `<div class="bubble" style="color: rgba(255,255,255,0.5); font-style: italic;"><i class="fa-solid fa-circle-notch fa-spin" style="color: #fff; margin-right: 8px;"></i> Analiz edilir...</div>`;chatBox.appendChild(loadDiv);chatBox.scrollTop = chatBox.scrollHeight;try {const res = await fetch('/chat', {method: 'POST',headers: {'Content-Type': 'application/json'},// Hansı rejimdə olduğumuzu da arxa plana göndəririk (Gələcəkdə EGR logikası üçün)body: JSON.stringify({ message: text, history: chats[activeChatId].messages, mode: currentAiMode })});const data = await res.json();6 unmodified linesappendMessageUI('bot', 'Sistemə qoşulmada xəta yarandı.', false);}}function appendMessageUI(sender, content, save = false, isHTML = false) {const div = document.createElement('div');div.className = `message msg-${sender}`;4 unmodified lineschatBox.scrollTop = chatBox.scrollHeight;if (save) { chats[activeChatId].messages.push({ sender, content, isHTML }); saveDB(); }}function typeWriterEffect(sender, fullText) {const div = document.createElement('div');div.className = `message msg-${sender}`;14 unmodified lines}type();}inputField.addEventListener('keypress', (e) => { if (e.key === 'Enter') sendMessage(); });</script></body></html>"""# ==========================================# BACKEND BEYİN (Limitsiz Şəkil API + Llama 3.3)# ==========================================@app.route('/')def index():return render_template_string(HTML_TEMPLATE)4 unmodified linesdata = request.jsonuser_msg = data.get("message", "").strip()history = data.get("history", [])mode = data.get("mode", "ExyposAi") # Front-end-dən gələn rejim seçimi# 1. YENİ ŞƏKİL MƏNTİQİ (Limitsiz və Pulsuz Pollinations API)if user_msg.lower().startswith(("/sekil", "/şəkil", "/image")):prompt = re.sub(r"^/(sekil|şəkil|image)\s*", "", user_msg, flags=re.IGNORECASE).strip()# Şəklin keyfiyyətini artırmaq üçünenhanced_prompt = f"Masterpiece, ultra detailed, 4k resolution, highly realistic: {prompt}"safe_prompt = urllib.parse.quote(enhanced_prompt)# 402 Xətası verməyən limitsiz API linkiimg_url = f"https://image.pollinations.ai/prompt/{safe_prompt}?width=1024&height=1024&nologo=true"return jsonify({"type": "image", "content": f'<img src="{img_url}">' })# 2. META LLAMA 3.3 MƏNTİQİ (Groq vasitəsilə)# Əgər EGR rejimindəyiksə, gələcəkdə bura sənin xüsusi $T_s$ analizi kodları əlavə olunacaqif mode == "ExyposGReco":sys_prompt = "Sən ExyposGReco-san (EGR). Sənin əsas vəzifən sənə göndərilən məlumatların və linklərin doğruluğunu (Fake/Real) analiz etməkdir. İstifadəçiyə bir skaner kimi ciddi və analitik dildə cavab ver."else:sys_prompt = """Sən ExyposAI-san. QAYDALAR:1. Əgər "adın nədir" və ya "kim yaradıb" soruşsalar, DƏQİQ BELƏ DE: 'Mən ExyposAi, IAHAI tərəfindən inkişaf etdirilən süni intellektəm. IAHAI: Innovative Artificial Hub of Advanced Intelligence.'2. İstifadəçi hansı dildə yazırsa, O DİLDƏ cavab ver.3. Sən çox ağıllısan, sürətlisən. Şəkil çəkmək üçün istifadəçiyə '/sekil [mətn]' yazmağı xatırlat."""msgs = [{"role": "system", "content": sys_prompt}]for m in history[-10:]:role = "user" if m['sender'] == 'user' else "assistant"if not m.get('isHTML'):msgs.append({"role": role, "content": m['content']})msgs.append({"role": "user", "content": user_msg})completion = client_groq.chat.completions.create(model="llama-3.3-70b-versatile",messages=msgs,temperature=0.7,max_tokens=1024)return jsonify({"type": "text", "content": completion.choices[0].message.content})except Exception as e:print(f"XƏTA: {e}")12345678910111213142 unmodified lines17181920212223242526272812 unmodified lines4142434445464748492 unmodified lines5253545556575816 unmodified lines757677787980811 unmodified line838485868788897 unmodified lines97989910010110210315 unmodified lines1191201211221231241253 unmodified lines12913013113213313413513613713813914014114214314414514652 unmodified lines19920020120220320410 unmodified lines2152162172182192202215 unmodified lines2272282292302312322335 unmodified lines2392402412422432442452462472482492502512522532542552562572582592602 unmodified lines2632642652662672682692702712722732742752762772782792802812822832849 unmodified lines2942952962972982997 unmodified lines3073083093103113123133143153163173183 unmodified lines3223233243253263273 unmodified lines3313323333343353363373383393403413423433441 unmodified line3463473483493503513523533543556 unmodified lines3623633643653663674 unmodified lines37237337437537637714 unmodified lines3923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524 unmodified lines457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513\import osimport ioimport base64import reimport urllib.parseimport urllib.requestfrom flask import Flask, render_template_string, request, jsonifyfrom huggingface_hub import InferenceClientfrom groq import Groqimport cv2import numpy as npapp = Flask(__name__)2 unmodified linesGROQ_API_KEY = os.getenv("GROQ_API_KEY")client_hf = InferenceClient(api_key=HF_TOKEN) if HF_TOKEN else Noneclient_groq = Groq(api_key=GROQ_API_KEY) if GROQ_API_KEY else None# ==========================================# FRONTEND (AĞ-QARA-BOZ & CINEMATIC BLUR) - HEÇ NƏYƏ TOXUNULMAYIB# ==========================================HTML_TEMPLATE = """<!DOCTYPE html><html lang="az"><head><meta charset="UTF-8">12 unmodified lines--exypos-grad: linear-gradient(135deg, #ffffff, #555555);--bubble-bot-grad: linear-gradient(135deg, #111111, #222222);}* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }body { background-color: var(--bg-dark); color: var(--text-main); height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }/* --- ARXA PLAN OBYEKTLƏRİ (Tüstü/Boz hərəkət) --- */.ambient-bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: #050505; }.orb { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.3; will-change: transform; }2 unmodified lines@keyframes float1 { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(25vw, 35vh) scale(1.1); } }@keyframes float2 { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(-35vw, -25vh) scale(1.2); } }/* --- YENİ CINEMATIC BLUR GİRİŞ (SPLASH) ANİMASİYASI --- */#splash {position: fixed; inset: 0;16 unmodified lines@keyframes cinematicReveal { 100% { opacity: 1; filter: blur(0); transform: scale(1); } }@keyframes subReveal { 100% { opacity: 0.6; filter: blur(0); transform: translateY(0); } }/* --- ÜST PANEL VƏ GOOGLE GİRİŞ --- */.top-bar { position: fixed; top: 0; left: 0; width: 100%; height: 70px; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; z-index: 1000; pointer-events: none; }.menu-btn { pointer-events: auto; background: rgba(255,255,255,0.03); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.08); width: 45px; height: 45px; border-radius: 12px; color: var(--color-white); display: flex; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; transition: 0.4s; z-index: 2500; }1 unmodified line.login-btn { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.05); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1); padding: 8px 18px; border-radius: 30px; color: var(--color-white); cursor: pointer; font-weight: 500; transition: 0.3s; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }.login-btn:hover { background: rgba(255,255,255,0.15); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(255,255,255,0.1); }.login-btn img { width: 20px; height: 20px; filter: grayscale(100%) brightness(150%); }/* --- SOL SİDEBAR --- */.sidebar { position: fixed; top: 0; left: -320px; width: 300px; height: 100%; background: rgba(10, 10, 10, 0.85); backdrop-filter: blur(35px); border-right: 1px solid rgba(255,255,255,0.05); display: flex; flex-direction: column; padding: 90px 20px 20px 20px; z-index: 2000; transition: left 0.5s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: 20px 0 50px rgba(0,0,0,0.8); }.sidebar.open { left: 0; }7 unmodified lines.history-item { padding: 14px 16px; border-radius: 12px; margin-bottom: 8px; cursor: pointer; color: var(--text-muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(255,255,255,0.02); transition: 0.3s; border: 1px solid transparent; }.history-item:hover { background: rgba(255,255,255,0.08); color: var(--color-white); }.history-item.active { background: rgba(255, 255, 255, 0.1); border-left: 3px solid var(--color-white); color: var(--color-white); }/* --- LIQUID GLASS CHAT ZONASI --- */.chat-area { flex: 1; display: flex; flex-direction: column; padding-top: 80px; position: relative; z-index: 10; align-items: center; }.glass-container { width: 98%; max-width: 1400px; height: calc(100vh - 180px); background: radial-gradient(circle at top left, rgba(255,255,255,0.04), rgba(0,0,0,0.4)); backdrop-filter: blur(40px) saturate(120%); -webkit-backdrop-filter: blur(40px) saturate(120%); border: 1px solid rgba(255, 255, 255, 0.05); border-top: 1px solid rgba(255, 255, 255, 0.1); border-left: 1px solid rgba(255, 255, 255, 0.1); border-radius: 35px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 60px rgba(0,0,0,0.8), inset 0 0 20px rgba(255,255,255,0.01); }15 unmodified lines.typing-cursor::after { content: '▌'; animation: blink 1s step-end infinite; color: var(--color-white); margin-left: 6px; opacity: 0.8; }@keyframes blink { 50% { opacity: 0; } }/* --- İNPUT ZONASI & PLUS MENU --- */.input-zone { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); width: 90%; max-width: 1000px; z-index: 100; }3 unmodified lines.mode-btn { background: transparent; color: var(--text-muted); border: none; padding: 12px 20px; border-radius: 12px; cursor: pointer; text-align: left; font-size: 14px; transition: 0.2s; display: flex; align-items: center; gap: 12px; font-weight: 500; }.mode-btn:hover { background: rgba(255,255,255,0.05); color: var(--color-white); }.mode-btn.active { background: rgba(255,255,255,0.1); color: var(--color-white); border-left: 3px solid var(--color-white); }.input-box { display: flex; align-items: center; background: rgba(15, 15, 15, 0.85); backdrop-filter: blur(25px); border: 1px solid rgba(255,255,255,0.15); border-radius: 35px; padding: 12px 18px 12px 15px; box-shadow: 0 20px 50px rgba(0,0,0,0.8); transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1); }.input-box:focus-within { border-color: rgba(255, 255, 255, 0.5); box-shadow: 0 20px 60px rgba(255, 255, 255, 0.1); transform: translateY(-3px); }.plus-btn { background: transparent; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; padding: 0 15px; transition: 0.3s; display: flex; align-items: center; justify-content: center; height: 100%; }.plus-btn:hover { color: var(--color-white); transform: rotate(90deg); }.input-box input { flex: 1; background: transparent; border: none; color: var(--color-white); font-size: 16px; outline: none; padding: 10px 0; font-weight: 300; letter-spacing: 0.5px; }.input-box input::placeholder { color: rgba(255,255,255,0.3); transition: 0.3s; }.send-btn { width: 48px; height: 48px; border-radius: 50%; border: none; background: var(--color-white); color: black; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.4s; box-shadow: 0 5px 15px rgba(255,255,255,0.1); }.send-btn:hover { transform: scale(1.1) rotate(15deg); box-shadow: 0 8px 25px rgba(255,255,255,0.3); background: #e0e0e0; }/* Limit Modalı */#limit-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(20px); z-index: 3000; display: none; align-items: center; justify-content: center; opacity: 0; transition: 0.6s; }.modal-content { background: rgba(20,20,20,0.95); border: 1px solid rgba(255,255,255,0.1); padding: 50px 40px; border-radius: 25px; text-align: center; max-width: 420px; box-shadow: 0 30px 70px rgba(0,0,0,0.8); }52 unmodified lines<i class="fa-solid fa-fingerprint" style="color: #b0b0b0;"></i> ExyposGReco (EGR)</button></div><div class="input-box"><button class="plus-btn" onclick="toggleModeMenu()"><i class="fa-solid fa-plus"></i></button><input type="text" id="user-input" placeholder="Exypos-a yaz və ya /sekil [mətn]..." autocomplete="off">10 unmodified lines</button></div></div><script>const DB_NAME = 'EXYPOS_ULTRA_MAX_DB';let chats = JSON.parse(localStorage.getItem(DB_NAME)) || {};5 unmodified linesconst chatBox = document.getElementById('chat-box');const inputField = document.getElementById('user-input');window.onload = () => {setTimeout(() => {document.getElementById('splash').style.opacity = '0';5 unmodified lineselse loadChat(activeChatId);renderHistory();};// Rejim Menyusu Funksiyalarıfunction toggleModeMenu() {document.getElementById('mode-menu').classList.toggle('active');}function setAiMode(mode) {currentAiMode = mode;document.querySelectorAll('.mode-btn').forEach(b => b.classList.remove('active'));event.currentTarget.classList.add('active');toggleModeMenu();if(mode === 'ExyposGReco') {inputField.placeholder = "EGR Scanner: Link və ya analiz mətni at...";} else {inputField.placeholder = "Exypos-a yaz və ya /sekil [mətn]...";}}// Menyunu kənara basanda bağlamaq üçündocument.addEventListener('click', function(event) {const menu = document.getElementById('mode-menu');2 unmodified linesmenu.classList.remove('active');}});function toggleSidebar() {document.getElementById('sidebar').classList.toggle('open');document.getElementById('sb-overlay').classList.toggle('open');}function saveDB() {localStorage.setItem(DB_NAME, JSON.stringify(chats));localStorage.setItem('EXYPOS_ACTIVE_MAX', activeChatId);renderHistory();}function createNewChat() {const id = 'chat_' + Date.now();chats[id] = { title: "Yeni Söhbət", messages: [] };activeChatId = id; saveDB(); loadChat(id);if(window.innerWidth <= 768) toggleSidebar();}function loadChat(id) {activeChatId = id; saveDB(); chatBox.innerHTML = '';9 unmodified lineschats[id].messages.forEach(msg => appendMessageUI(msg.sender, msg.content, false, msg.isHTML));}}function renderHistory() {const historyList = document.getElementById('history-list');historyList.innerHTML = '';7 unmodified lineshistoryList.appendChild(div);});}function checkLoginState() {if (isLoggedIn) {document.getElementById('btn-login').innerHTML = `<i class="fa-solid fa-user-check" style="color:#fff;"></i> Tunar (Aktiv)`;document.getElementById('limit-modal').style.display = 'none';}}function simulateGoogleLogin() {document.getElementById('login-text').innerText = "Bağlanır...";setTimeout(() => {3 unmodified linessetTimeout(() => document.getElementById('limit-modal').style.display = 'none', 600);}, 1200);}async function sendMessage() {const text = inputField.value.trim();if (!text) return;3 unmodified linesmodal.style.display = 'flex'; setTimeout(() => modal.style.opacity = '1', 50);return;}if (chats[activeChatId].messages.length === 0) {chats[activeChatId].title = text.substring(0, 25) + "...";chatBox.innerHTML = '';}appendMessageUI('user', text, true);inputField.value = '';if(!isLoggedIn) { msgCount++; localStorage.setItem('EXYPOS_MSG_COUNT', msgCount.toString()); }const loadingId = 'load_' + Date.now();const loadDiv = document.createElement('div');loadDiv.className = 'message msg-bot';1 unmodified lineloadDiv.innerHTML = `<div class="bubble" style="color: rgba(255,255,255,0.5); font-style: italic;"><i class="fa-solid fa-circle-notch fa-spin" style="color: #fff; margin-right: 8px;"></i> Analiz edilir...</div>`;chatBox.appendChild(loadDiv);chatBox.scrollTop = chatBox.scrollHeight;try {const res = await fetch('/chat', {method: 'POST',headers: {'Content-Type': 'application/json'},body: JSON.stringify({ message: text, history: chats[activeChatId].messages, mode: currentAiMode })});const data = await res.json();6 unmodified linesappendMessageUI('bot', 'Sistemə qoşulmada xəta yarandı.', false);}}function appendMessageUI(sender, content, save = false, isHTML = false) {const div = document.createElement('div');div.className = `message msg-${sender}`;4 unmodified lineschatBox.scrollTop = chatBox.scrollHeight;if (save) { chats[activeChatId].messages.push({ sender, content, isHTML }); saveDB(); }}function typeWriterEffect(sender, fullText) {const div = document.createElement('div');div.className = `message msg-${sender}`;14 unmodified lines}type();}inputField.addEventListener('keypress', (e) => { if (e.key === 'Enter') sendMessage(); });</script></body></html>"""# ==========================================# BACKEND BEYİN (Limitsiz API, Llama 3.3 & EGR Analizatoru)# ==========================================# --- EGR VİDEO/ŞƏKİL ANALİZ FUNKSİYASI ---def analyze_media_from_url(url):try:# Linkdən medianı yaddaşa oxuyuruq (Qadağalardan keçmək üçün User-Agent əlavə edilib)req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})resp = urllib.request.urlopen(req)arr = np.asarray(bytearray(resp.read()), dtype=np.uint8)img = cv2.imdecode(arr, -1)if img is None:return "❌ Medianı oxumaq mümkün olmadı. Zəhmət olmasa sonu .jpg, .png olan birbaşa şəkil linki göndərin."# 1. PİKSEL VƏ KÜY (NOISE) ANALİZİgray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)# Laplacian variance görüntü küyünü və hamarlığı yoxlayır (AI adətən qeyri-təbii hamar olur)variance = cv2.Laplacian(gray, cv2.CV_64F).var()# 2. ÜZ VƏ GÖZ ANALİZİ (Baza səviyyə)face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')faces = face_cascade.detectMultiScale(gray, 1.3, 5)# HESABAT YARATMAQ (HTML formatında çıxarırıq ki, dizaynlı görünsün)report = f"🔍 <b>ExyposGReco (EGR) Skan Nəticəsi:</b><br><br>"report += f"📊 <b>Piksel/Kölgə Analizi (Variance):</b> {variance:.2f}<br>"if variance < 100:report += "⚠️ <span style='color:#ff4444;'>DİQQƏT:</span> Piksellərdə qeyri-təbii hamarlıq və kölgə pozuntusu var. (Diffusion/GAN əlamətləri)<br>"else:report += "✅ Piksellərin və kölgələrin paylanması təbii küyə (noise) uyğundur.<br>"if len(faces) > 0:report += f"👁️ <b>Obyekt Analizi:</b> {len(faces)} üz aşkarlandı. Asimmetriya skan edildi.<br>"else:report += "👤 İnsan üzü aşkar edilmədi, ümumi obyekt analizi aparıldı.<br>"# YEKUN DAMĞAreport += "<br>"if variance < 100:report += "🛑 <b style='color:#ff4444;'>YEKUN QƏRAR: DAMĞALANDI - SAXTA (AI GENERATED)</b>"else:report += "🟢 <b style='color:#00ff00;'>YEKUN QƏRAR: TƏBİİ (REAL)</b>"return reportexcept Exception as e:return f"❌ EGR Skan Xətası: Linkin oxuna bilən media faylına aid olduğundan əmin olun."@app.route('/')def index():return render_template_string(HTML_TEMPLATE)4 unmodified linesdata = request.jsonuser_msg = data.get("message", "").strip()history = data.get("history", [])mode = data.get("mode", "ExyposAi")# 1. YENİ ŞƏKİL YARATMAQif user_msg.lower().startswith(("/sekil", "/şəkil", "/image")):prompt = re.sub(r"^/(sekil|şəkil|image)\s*", "", user_msg, flags=re.IGNORECASE).strip()enhanced_prompt = f"Masterpiece, ultra detailed, 4k resolution, highly realistic: {prompt}"safe_prompt = urllib.parse.quote(enhanced_prompt)img_url = f"https://image.pollinations.ai/prompt/{safe_prompt}?width=1024&height=1024&nologo=true"return jsonify({"type": "image", "content": f'<img src="{img_url}">' })# 2. EGR (EXYPOS GRECO) MƏNTİQİ - VİDEO/ŞƏKİL ANALİZİif mode == "ExyposGReco":# Əgər məktubda URL (link) varsa, arxa planda analizi işə salırıqif "http" in user_msg:urls = re.findall(r'(https?://[^\s]+)', user_msg)if urls:target_url = urls[0]analysis_result = analyze_media_from_url(target_url)# "image" type kimi göndəririk ki, frontend HTML formatını dərhal oxusun, hərflə yazıb dizaynı pozmasınreturn jsonify({"type": "image", "content": analysis_result})# Link yoxdursa, EGR skaneri kimi ciddi danışırsys_prompt = "Sən ExyposGReco-san (EGR). Sənin əsas vəzifən sənə göndərilən linklərin doğruluğunu (Fake/Real) analiz etməkdir. İstifadəçiyə bir skaner kimi ciddi və analitik dildə cavab ver. Qısa və konkret ol."# 3. STANDART EXYPOS AI MƏNTİQİelse:sys_prompt = """Sən ExyposAI-san. QAYDALAR:1. Əgər "adın nədir" və ya "kim yaradıb" soruşsalar, DƏQİQ BELƏ DE: 'Mən ExyposAi, IAHAI tərəfindən inkişaf etdirilən süni intellektəm.'2. İstifadəçi hansı dildə yazırsa, O DİLDƏ cavab ver.3. Sən çox ağıllısan, sürətlisən. Şəkil çəkmək üçün istifadəçiyə '/sekil [mətn]' yazmağı xatırlat."""msgs = [{"role": "system", "content": sys_prompt}]for m in history[-10:]:role = "user" if m['sender'] == 'user' else "assistant"if not m.get('isHTML'):msgs.append({"role": role, "content": m['content']})msgs.append({"role": "user", "content": user_msg})if client_groq:completion = client_groq.chat.completions.create(model="llama-3.3-70b-versatile",messages=msgs,temperature=0.7,max_tokens=1024)response_text = completion.choices[0].message.contentelse:response_text = "API Key eksikdir. Server xətası."return jsonify({"type": "text", "content": response_text})except Exception as e:print(f"XƏTA: {e}")
app.py+99-63