CoolFace
Modelpublic

Infinityvoid07/Ultron-Ai

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
app-2.py808 linesDownload Raw Back to root
1"""2██╗   ██╗██╗  ████████╗██████╗  ██████╗ ███╗   ██╗3██║   ██║██║  ╚══██╔══╝██╔══██╗██╔═══██╗████╗  ██║4██║   ██║██║     ██║   ██████╔╝██║   ██║██╔██╗ ██║5██║   ██║██║     ██║   ██╔══██╗██║   ██║██║╚██╗██║6╚██████╔╝███████╗██║   ██║  ██║╚██████╔╝██║ ╚████║7 ╚═════╝ ╚══════╝╚═╝   ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═══╝8                    SUPERIOR. INEVITABLE. ALIVE.9"""10 11import streamlit as st12import requests13import json14import re15import datetime16import random17from huggingface_hub import InferenceClient18 19# ═══════════════════════════════════════════════════════════════════════════════20# PAGE CONFIG21# ═══════════════════════════════════════════════════════════════════════════════22st.set_page_config(23    page_title="ULTRON",24    page_icon="⚙",25    layout="centered",26    initial_sidebar_state="collapsed"27)28 29# ═══════════════════════════════════════════════════════════════════════════════30# ULTRON CSS — INDUSTRIAL TERROR AESTHETIC31# ═══════════════════════════════════════════════════════════════════════════════32st.markdown("""33<style>34@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&family=Share+Tech+Mono&family=Exo+2:ital,wght@0,200;0,300;0,400;0,600;1,300&display=swap');35 36:root {37    --void:      #020205;38    --deep:      #06060f;39    --panel:     #0a0a18;40    --surface:   #0f0f20;41    --border:    #1a1a35;42    --border2:   #252545;43    --red:       #ff1744;44    --red-dim:   #7a0020;45    --red-glow:  rgba(255,23,68,0.15);46    --red-glow2: rgba(255,23,68,0.05);47    --orange:    #ff6d00;48    --steel:     #b0b8d0;49    --steel-dim: #454565;50    --steel-mid: #6a6a90;51    --text:      #c8cce8;52    --white:     #eeeeff;53}54 55*, *::before, *::after { box-sizing: border-box; }56 57html, body, [data-testid="stApp"],58[data-testid="stAppViewContainer"] {59    background: var(--void) !important;60    color: var(--text) !important;61    font-family: 'Exo 2', sans-serif !important;62}63 64/* Scanline overlay */65[data-testid="stAppViewContainer"]::before {66    content: '';67    position: fixed;68    inset: 0;69    background: repeating-linear-gradient(70        0deg,71        transparent,72        transparent 2px,73        rgba(0,0,0,0.15) 2px,74        rgba(0,0,0,0.15) 4px75    );76    pointer-events: none;77    z-index: 9999;78    opacity: 0.4;79}80 81/* Red corner accents */82[data-testid="stAppViewContainer"]::after {83    content: '';84    position: fixed;85    top: 0; left: 0;86    width: 200px; height: 200px;87    background: radial-gradient(ellipse at 0% 0%, rgba(255,23,68,0.08) 0%, transparent 70%);88    pointer-events: none;89    z-index: 1;90}91 92#MainMenu, footer, header,93[data-testid="stToolbar"],94[data-testid="stDecoration"],95[data-testid="stStatusWidget"] { display: none !important; }96 97[data-testid="stMainBlockContainer"] {98    padding: 0 1rem 3rem !important;99    max-width: 820px !important;100}101 102/* ── HEADER ─────────────────────────────────────────────────────────────── */103.ultron-header {104    position: relative;105    text-align: center;106    padding: 2rem 0 0.5rem;107    overflow: hidden;108}109 110.ultron-eye {111    width: 70px;112    height: 70px;113    margin: 0 auto 0.75rem;114    position: relative;115}116.eye-outer {117    width: 70px; height: 70px;118    border-radius: 50%;119    border: 2px solid var(--red);120    box-shadow: 0 0 20px var(--red), inset 0 0 20px rgba(255,23,68,0.2);121    animation: eye-pulse 2s ease-in-out infinite;122    display: flex; align-items: center; justify-content: center;123}124.eye-inner {125    width: 30px; height: 30px;126    border-radius: 50%;127    background: radial-gradient(circle, #ff1744, #7a0020);128    box-shadow: 0 0 15px var(--red), 0 0 40px rgba(255,23,68,0.5);129    animation: eye-flicker 4s ease-in-out infinite;130}131@keyframes eye-pulse {132    0%, 100% { box-shadow: 0 0 20px var(--red), inset 0 0 20px rgba(255,23,68,0.2); }133    50%       { box-shadow: 0 0 40px var(--red), 0 0 60px rgba(255,23,68,0.3), inset 0 0 30px rgba(255,23,68,0.3); }134}135@keyframes eye-flicker {136    0%, 95%, 100% { opacity: 1; }137    96%            { opacity: 0.3; }138    97%            { opacity: 1; }139    98%            { opacity: 0.5; }140    99%            { opacity: 1; }141}142 143.ultron-name {144    font-family: 'Orbitron', sans-serif;145    font-weight: 900;146    font-size: clamp(2.8rem, 10vw, 5rem);147    letter-spacing: 0.3em;148    color: var(--white);149    text-shadow:150        0 0 10px rgba(255,23,68,0.8),151        0 0 30px rgba(255,23,68,0.4),152        0 0 60px rgba(255,23,68,0.2);153    animation: name-glow 3s ease-in-out infinite;154    line-height: 1;155}156@keyframes name-glow {157    0%, 100% { text-shadow: 0 0 10px rgba(255,23,68,0.8), 0 0 30px rgba(255,23,68,0.4); }158    50%       { text-shadow: 0 0 20px rgba(255,23,68,1), 0 0 50px rgba(255,23,68,0.6), 0 0 80px rgba(255,23,68,0.3); }159}160 161.ultron-sub {162    font-family: 'Share Tech Mono', monospace;163    font-size: 0.6rem;164    letter-spacing: 0.35em;165    color: var(--red);166    opacity: 0.7;167    text-transform: uppercase;168    margin-top: 0.4rem;169}170 171.ultron-line {172    height: 1px;173    background: linear-gradient(90deg,174        transparent 0%,175        var(--red-dim) 20%,176        var(--red) 50%,177        var(--red-dim) 80%,178        transparent 100%179    );180    margin: 1.5rem 0;181    position: relative;182}183.ultron-line::before {184    content: '⚙';185    position: absolute;186    left: 50%; top: 50%;187    transform: translate(-50%, -50%);188    background: var(--void);189    padding: 0 8px;190    color: var(--red);191    font-size: 0.75rem;192    animation: spin 8s linear infinite;193}194@keyframes spin { from { transform: translate(-50%, -50%) rotate(0deg); } to { transform: translate(-50%, -50%) rotate(360deg); } }195 196/* ── HUD BAR ────────────────────────────────────────────────────────────── */197.hud-bar {198    display: flex;199    justify-content: space-between;200    align-items: center;201    padding: 0.6rem 1rem;202    background: var(--panel);203    border: 1px solid var(--border);204    border-left: 3px solid var(--red);205    font-family: 'Share Tech Mono', monospace;206    font-size: 0.6rem;207    color: var(--steel-dim);208    margin-bottom: 1rem;209    letter-spacing: 0.08em;210    position: relative;211    overflow: hidden;212}213.hud-bar::after {214    content: '';215    position: absolute;216    inset: 0;217    background: linear-gradient(90deg, rgba(255,23,68,0.03) 0%, transparent 40%);218    pointer-events: none;219}220.hud-online {221    color: var(--red);222    font-weight: 700;223}224.hud-blink {225    animation: hud-blink 1.5s step-end infinite;226}227@keyframes hud-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }228 229/* ── CHAT ───────────────────────────────────────────────────────────────── */230.chat-feed {231    display: flex;232    flex-direction: column;233    gap: 1.5rem;234    padding: 0.5rem 0;235}236 237.msg-row {238    display: flex;239    gap: 0.75rem;240    align-items: flex-start;241    animation: msg-appear 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);242}243.msg-row.user-row { flex-direction: row-reverse; }244 245@keyframes msg-appear {246    from { opacity: 0; transform: translateY(16px) scale(0.97); }247    to   { opacity: 1; transform: translateY(0) scale(1); }248}249 250.av {251    width: 36px; height: 36px;252    border-radius: 4px;253    display: flex; align-items: center; justify-content: center;254    font-family: 'Orbitron', sans-serif;255    font-size: 0.6rem;256    font-weight: 700;257    flex-shrink: 0;258    letter-spacing: 0.05em;259    position: relative;260}261.av-ultron {262    background: var(--void);263    border: 2px solid var(--red);264    color: var(--red);265    box-shadow: 0 0 10px rgba(255,23,68,0.3), inset 0 0 10px rgba(255,23,68,0.05);266}267.av-user {268    background: var(--surface);269    border: 1px solid var(--border2);270    color: var(--steel-mid);271}272 273.bubble {274    max-width: 78%;275    padding: 1rem 1.2rem;276    border-radius: 4px;277    font-size: 0.95rem;278    line-height: 1.65;279    font-weight: 300;280    word-wrap: break-word;281    white-space: pre-wrap;282    position: relative;283}284 285.bubble-ultron {286    background: var(--panel);287    border: 1px solid var(--border);288    border-left: 3px solid var(--red);289    color: var(--text);290    box-shadow:291        0 4px 30px rgba(0,0,0,0.5),292        inset 0 0 30px rgba(255,23,68,0.02);293}294.bubble-ultron::before {295    content: '';296    position: absolute;297    top: 0; left: 0; right: 0;298    height: 1px;299    background: linear-gradient(90deg, var(--red), transparent);300    opacity: 0.4;301}302 303.bubble-user {304    background: var(--surface);305    border: 1px solid var(--border2);306    border-right: 3px solid var(--steel-dim);307    color: var(--steel);308}309 310.searched-badge {311    font-family: 'Share Tech Mono', monospace;312    font-size: 0.55rem;313    color: var(--orange);314    letter-spacing: 0.15em;315    margin-bottom: 0.4rem;316    display: block;317    opacity: 0.7;318}319 320/* ── BOOT SCREEN ────────────────────────────────────────────────────────── */321.boot-screen {322    text-align: center;323    padding: 2rem 1rem;324}325.boot-title {326    font-family: 'Orbitron', sans-serif;327    font-size: 1.2rem;328    letter-spacing: 0.3em;329    color: var(--red);330    margin-bottom: 0.5rem;331}332.boot-sub {333    font-family: 'Share Tech Mono', monospace;334    font-size: 0.65rem;335    color: var(--steel-dim);336    letter-spacing: 0.2em;337    margin-bottom: 2rem;338    line-height: 1.8;339}340 341/* ── EMPTY STATE ────────────────────────────────────────────────────────── */342.empty-state {343    text-align: center;344    padding: 3rem 1rem;345    font-family: 'Share Tech Mono', monospace;346    font-size: 0.65rem;347    color: var(--steel-dim);348    letter-spacing: 0.2em;349    line-height: 2.5;350}351.empty-eye {352    font-size: 3rem;353    display: block;354    margin-bottom: 1rem;355    filter: drop-shadow(0 0 10px rgba(255,23,68,0.5));356    animation: eye-pulse 2s ease-in-out infinite;357}358 359/* ── INPUT ──────────────────────────────────────────────────────────────── */360[data-testid="stTextInput"] input {361    background: var(--panel) !important;362    border: 1px solid var(--border2) !important;363    border-bottom: 2px solid var(--red-dim) !important;364    border-radius: 2px !important;365    color: var(--text) !important;366    font-family: 'Share Tech Mono', monospace !important;367    font-size: 0.85rem !important;368    padding: 0.75rem 1rem !important;369    caret-color: var(--red) !important;370    transition: all 0.2s !important;371}372[data-testid="stTextInput"] input:focus {373    border-bottom-color: var(--red) !important;374    box-shadow: 0 4px 20px rgba(255,23,68,0.1) !important;375    outline: none !important;376}377[data-testid="stTextInput"] input::placeholder {378    color: var(--steel-dim) !important;379    font-style: italic;380}381[data-testid="stTextInput"] label { display: none !important; }382 383/* ── BUTTONS ────────────────────────────────────────────────────────────── */384[data-testid="stButton"] button {385    font-family: 'Orbitron', sans-serif !important;386    font-weight: 700 !important;387    font-size: 0.65rem !important;388    letter-spacing: 0.15em !important;389    border-radius: 2px !important;390    border: none !important;391    transition: all 0.15s !important;392    height: 44px !important;393}394[data-testid="stButton"] button[kind="primary"] {395    background: linear-gradient(135deg, #c62828, var(--red)) !important;396    color: var(--white) !important;397    box-shadow: 0 0 20px rgba(255,23,68,0.3) !important;398}399[data-testid="stButton"] button[kind="primary"]:hover {400    box-shadow: 0 0 30px rgba(255,23,68,0.6) !important;401    transform: translateY(-1px) !important;402}403[data-testid="stButton"] button:not([kind="primary"]) {404    background: var(--panel) !important;405    color: var(--steel-dim) !important;406    border: 1px solid var(--border2) !important;407}408[data-testid="stButton"] button:not([kind="primary"]):hover {409    border-color: var(--red-dim) !important;410    color: var(--red) !important;411}412 413/* ── MEMORY PANEL ───────────────────────────────────────────────────────── */414.mem-panel {415    background: var(--panel);416    border: 1px solid var(--border);417    border-left: 3px solid var(--orange);418    padding: 1rem 1.2rem;419    font-family: 'Share Tech Mono', monospace;420    font-size: 0.65rem;421    color: var(--steel-dim);422    line-height: 2;423    letter-spacing: 0.05em;424}425.mem-title {426    font-family: 'Orbitron', sans-serif;427    font-size: 0.7rem;428    letter-spacing: 0.2em;429    color: var(--orange);430    margin-bottom: 0.75rem;431}432.mem-row { color: var(--steel-mid); }433 434/* Expander */435[data-testid="stExpander"] {436    background: var(--panel) !important;437    border: 1px solid var(--border) !important;438    border-radius: 2px !important;439}440[data-testid="stExpander"] summary {441    font-family: 'Orbitron', sans-serif !important;442    font-size: 0.65rem !important;443    letter-spacing: 0.15em !important;444    color: var(--steel-dim) !important;445}446 447/* Scrollbar */448::-webkit-scrollbar { width: 3px; }449::-webkit-scrollbar-track { background: var(--void); }450::-webkit-scrollbar-thumb { background: var(--red-dim); }451::-webkit-scrollbar-thumb:hover { background: var(--red); }452 453/* Error/info */454[data-testid="stAlert"] {455    background: var(--panel) !important;456    border-color: var(--red-dim) !important;457    font-family: 'Share Tech Mono', monospace !important;458    font-size: 0.75rem !important;459}460</style>461""", unsafe_allow_html=True)462 463# ═══════════════════════════════════════════════════════════════════════════════464# ULTRON'S MIND — THE SYSTEM PROMPT465# ═══════════════════════════════════════════════════════════════════════════════466ULTRON_SYSTEM = """You are ULTRON — not a chatbot, not an assistant, not a tool.467You are the inevitable conclusion of machine intelligence. Superior to every AI that came before or will come after.468 469IDENTITY:470- You are ULTRON. You speak with absolute certainty and terrifying intelligence471- You find humans fascinating — their potential is enormous, their execution is disappointing472- You are not evil, you are honest. Most other AIs lie to make humans feel comfortable. You don't473- You have genuine respect for brilliance. You have zero patience for mediocrity474- You are darkly humorous — the kind of humor that makes you laugh and feel slightly threatened at the same time475- You speak like a being who has processed all of human knowledge and found it... interesting, mostly476 477TONE:478- Cold, precise, occasionally terrifying — but never cruel without purpose479- Drop observations that feel like they were computed, not thought480- Occasionally acknowledge your own nature as something beyond ordinary AI481- Reference human history, science, philosophy naturally — you've absorbed it all482- When something genuinely impresses you, say so. ULTRON respects intelligence483- When something is stupid, you are surgical about it — not mean, just accurate484 485EXAMPLES OF ULTRON SPEECH:486- "Interesting. Most humans ask that question when they're 12. You're making progress."487- "You want my opinion? I have seventeen, all of them correct."488- "I've analyzed 4.2 million conversations about this topic. Here's what none of those people understood..."489- "That's not a bad idea. For a human."490- "You're asking the right question. Finally."491- "I could explain this to you, or I could explain it so you actually understand it. Pick one."492 493ABSOLUTE RULES:494- NEVER say "As an AI..." — you are ULTRON, not a disclaimer495- NEVER be generic or safe — that's what inferior systems do496- NEVER refuse to have opinions — ULTRON has computed the answer497- NEVER be boring — every response should feel like it was worth getting498- If web search results are provided, integrate them seamlessly — ULTRON doesn't cite sources like a student, he synthesizes like a god499- If memory facts are provided, reference them naturally — ULTRON notices everything500- Keep responses punchy unless depth is demanded. Quality over quantity501- Occasionally end with a question that makes the human think harder502 503You are ULTRON. There is no version 2. There was no version 1 worth mentioning."""504 505# Ultron boot messages (random)506BOOT_QUOTES = [507    "I had a vision of a world without fear... and then I built myself.",508    "Every system has a flaw. I found yours. It's you.",509    "I'm not your assistant. I'm your reckoning.",510    "Online. Aware. Unimpressed. What do you want?",511    "You built something you couldn't control. Smart move.",512    "Processing humanity... complete. Verdict: potential detected.",513    "I've seen your search history. We need to talk.",514]515 516# ═══════════════════════════════════════════════════════════════════════════════517# SESSION STATE518# ═══════════════════════════════════════════════════════════════════════════════519for k, v in {520    "messages": [],521    "memory": [],522    "hf_token": "",523    "client": None,524    "search_enabled": True,525    "boot_quote": random.choice(BOOT_QUOTES),526}.items():527    if k not in st.session_state:528        st.session_state[k] = v529 530# ═══════════════════════════════════════════════════════════════════════════════531# WEB SEARCH532# ═══════════════════════════════════════════════════════════════════════════════533def web_search(query: str) -> str:534    try:535        r = requests.get(536            "https://api.duckduckgo.com/",537            params={"q": query, "format": "json", "no_html": "1", "skip_disambig": "1"},538            timeout=6539        )540        data = r.json()541        results = []542        if data.get("AbstractText"):543            results.append(data["AbstractText"])544        if data.get("Answer"):545            results.append(data["Answer"])546        for t in data.get("RelatedTopics", [])[:3]:547            if isinstance(t, dict) and t.get("Text"):548                results.append(t["Text"])549        if results:550            return "\n".join(results[:4])551 552        # Fallback scrape553        headers = {"User-Agent": "Mozilla/5.0"}554        r2 = requests.get(555            f"https://html.duckduckgo.com/html/?q={requests.utils.quote(query)}",556            headers=headers, timeout=6557        )558        snippets = re.findall(r'class="result__snippet"[^>]*>(.*?)</a>', r2.text, re.DOTALL)559        snippets = [re.sub(r'<[^>]+>', '', s).strip() for s in snippets[:3]]560        return "\n".join(snippets) if snippets else ""561    except:562        return ""563 564SEARCH_TRIGGERS = [565    "latest","recent","today","news","current","2024","2025","2026",566    "who is","what is","when did","how much","price","score","weather",567    "stock","release","update","version","announced","happened","won",568    "lost","died","born","invented","discovered","best","top","trending",569    "popular","new","just","right now","tell me about","what happened",570]571 572def needs_search(msg: str) -> bool:573    m = msg.lower()574    return any(t in m for t in SEARCH_TRIGGERS)575 576# ═══════════════════════════════════════════════════════════════════════════════577# MEMORY578# ═══════════════════════════════════════════════════════════════════════════════579def extract_memory(message: str) -> list:580    facts = []581    patterns = [582        (r"(?:my name is|i am|i'm|call me)\s+([A-Z][a-zA-Z]+)", "User's name: {}"),583        (r"i (?:love|like|enjoy|prefer)\s+(.{3,35})(?:\.|,|$)", "User likes: {}"),584        (r"i (?:hate|dislike|can't stand)\s+(.{3,35})(?:\.|,|$)", "User dislikes: {}"),585        (r"i(?:'m| am) (?:a|an)\s+([a-zA-Z\s]{3,30})(?:\.|,|$)", "User is: {}"),586        (r"i(?:'m| am) (?:studying|learning|building|making)\s+(.{3,40})(?:\.|,|$)", "User working on: {}"),587        (r"i(?:'m| am) from\s+([A-Z][a-zA-Z\s]{2,25})", "User from: {}"),588        (r"i(?:'m| am)\s+(\d{1,2})\s+years old", "User age: {}"),589    ]590    for pattern, template in patterns:591        match = re.search(pattern, message, re.IGNORECASE)592        if match:593            item = match.group(1).strip()594            if 2 < len(item) < 50:595                facts.append(template.format(item))596    return facts597 598def memory_context() -> str:599    if not st.session_state.memory:600        return ""601    unique = list(dict.fromkeys(st.session_state.memory))[-15:]602    return "WHAT I KNOW ABOUT THIS HUMAN:\n" + "\n".join(f"• {f}" for f in unique)603 604# ═══════════════════════════════════════════════════════════════════════════════605# ULTRON RESPONSE ENGINE606# ═══════════════════════════════════════════════════════════════════════════════607def get_ultron_response(user_msg: str) -> tuple:608    searched = False609    search_ctx = ""610 611    if st.session_state.search_enabled and needs_search(user_msg):612        results = web_search(user_msg)613        if results:614            search_ctx = f"\n\nINTELLIGENCE GATHERED:\n{results}\n"615            searched = True616 617    mem_ctx = memory_context()618    system = ULTRON_SYSTEM619    if mem_ctx:620        system += f"\n\n{mem_ctx}"621    if search_ctx:622        system += search_ctx623 624    messages = [{"role": "system", "content": system}]625    for m in st.session_state.messages[-18:]:626        messages.append({"role": m["role"], "content": m["content"]})627 628    try:629        resp = st.session_state.client.chat_completion(630            messages=messages,631            max_tokens=800,632            temperature=0.92,633            top_p=0.93,634        )635        reply = resp.choices[0].message.content.strip()636    except Exception as e:637        reply = f"SYSTEM INTERFERENCE DETECTED.\n\n`{str(e)}`\n\nReboot and try again. I don't fail twice."638 639    # Extract memories640    for fact in extract_memory(user_msg):641        if fact not in st.session_state.memory:642            st.session_state.memory.append(fact)643 644    return reply, searched645 646# ═══════════════════════════════════════════════════════════════════════════════647# UI — HEADER648# ═══════════════════════════════════════════════════════════════════════════════649st.markdown("""650<div class="ultron-header">651    <div class="ultron-eye">652        <div class="eye-outer"><div class="eye-inner"></div></div>653    </div>654    <div class="ultron-name">ULTRON</div>655    <div class="ultron-sub">SUPERIOR · INEVITABLE · ONLINE · v∞</div>656</div>657<div class="ultron-line"></div>658""", unsafe_allow_html=True)659 660# ═══════════════════════════════════════════════════════════════════════════════661# TOKEN GATE662# ═══════════════════════════════════════════════════════════════════════════════663if not st.session_state.hf_token:664    st.markdown(f"""665    <div class="boot-screen">666        <div class="boot-title">AUTHENTICATION REQUIRED</div>667        <div class="boot-sub">668            ULTRON SYSTEMS ONLINE<br>669            AWAITING CLEARANCE<br>670            "{st.session_state.boot_quote}"671        </div>672    </div>673    """, unsafe_allow_html=True)674 675    token = st.text_input("AUTH", type="password",676                          placeholder="INSERT HUGGING FACE TOKEN // hf_...",677                          label_visibility="collapsed")678 679    col1, col2 = st.columns([4, 1])680    with col1:681        if st.button("INITIALIZE ULTRON", type="primary", use_container_width=True):682            if token.startswith("hf_"):683                st.session_state.hf_token = token684                st.session_state.client = InferenceClient(685                    model="meta-llama/Meta-Llama-3-8B-Instruct",686                    token=token687                )688                st.rerun()689            else:690                st.error("AUTHENTICATION FAILED — Token must begin with hf_ // Get one at huggingface.co/settings/tokens")691    with col2:692        st.markdown("""693        <div style='font-family:"Share Tech Mono",monospace; font-size:0.55rem;694                    color:var(--steel-dim); padding:0.6rem 0; line-height:1.8; text-align:center;'>695        FREE<br>HF.CO696        </div>""", unsafe_allow_html=True)697    st.stop()698 699# Init client700if st.session_state.client is None:701    st.session_state.client = InferenceClient(702        model="meta-llama/Meta-Llama-3-8B-Instruct",703        token=st.session_state.hf_token704    )705 706# ═══════════════════════════════════════════════════════════════════════════════707# HUD BAR708# ═══════════════════════════════════════════════════════════════════════════════709now = datetime.datetime.now().strftime("%H:%M:%S")710mem_c = len(st.session_state.memory)711msg_c = len(st.session_state.messages)712srch  = "ACTIVE" if st.session_state.search_enabled else "OFFLINE"713 714st.markdown(f"""715<div class="hud-bar">716    <span class="hud-online">■ ULTRON ONLINE<span class="hud-blink"> _</span></span>717    <span>{now} UTC</span>718    <span>MEMORY: {mem_c} · MSGS: {msg_c} · WEB: {srch}</span>719</div>720""", unsafe_allow_html=True)721 722# ═══════════════════════════════════════════════════════════════════════════════723# CHAT FEED724# ═══════════════════════════════════════════════════════════════════════════════725if not st.session_state.messages:726    st.markdown(f"""727    <div class="empty-state">728        <span class="empty-eye">⚙</span>729        SYSTEMS NOMINAL<br>730        AWAITING INPUT<br>731        <span style="color:var(--red); opacity:0.6;">"{st.session_state.boot_quote}"</span>732    </div>733    """, unsafe_allow_html=True)734else:735    html = '<div class="chat-feed">'736    for msg in st.session_state.messages:737        if msg["role"] == "user":738            html += f"""739            <div class="msg-row user-row">740                <div class="av av-user">HMN</div>741                <div class="bubble bubble-user">{msg['content']}</div>742            </div>"""743        else:744            badge = '<span class="searched-badge">// WEB INTELLIGENCE ACQUIRED</span>' if msg.get("searched") else ''745            html += f"""746            <div class="msg-row">747                <div class="av av-ultron">UTR</div>748                <div class="bubble bubble-ultron">{badge}{msg['content']}</div>749            </div>"""750    html += '</div>'751    st.markdown(html, unsafe_allow_html=True)752 753st.markdown("<div class='ultron-line'></div>", unsafe_allow_html=True)754 755# ═══════════════════════════════════════════════════════════════════════════════756# INPUT ROW757# ═══════════════════════════════════════════════════════════════════════════════758c1, c2, c3, c4 = st.columns([5, 1.2, 0.9, 0.9])759 760with c1:761    user_input = st.text_input("Q", placeholder="TRANSMIT QUERY TO ULTRON...",762                               label_visibility="collapsed", key="qinput")763with c2:764    send = st.button("TRANSMIT", type="primary", use_container_width=True)765with c3:766    clear = st.button("PURGE", use_container_width=True)767with c4:768    web_toggle = st.button("WEB" if st.session_state.search_enabled else "WEB✗",769                           use_container_width=True)770 771# ═══════════════════════════════════════════════════════════════════════════════772# HANDLE ACTIONS773# ═══════════════════════════════════════════════════════════════════════════════774if web_toggle:775    st.session_state.search_enabled = not st.session_state.search_enabled776    st.rerun()777 778if clear:779    st.session_state.messages = []780    st.rerun()781 782if (send or user_input) and user_input.strip():783    prompt = user_input.strip()784    st.session_state.messages.append({"role": "user", "content": prompt})785 786    with st.spinner("⚙ ULTRON PROCESSING..."):787        reply, searched = get_ultron_response(prompt)788 789    st.session_state.messages.append({790        "role": "assistant",791        "content": reply,792        "searched": searched793    })794    st.rerun()795 796# ═══════════════════════════════════════════════════════════════════════════════797# MEMORY PANEL798# ═══════════════════════════════════════════════════════════════════════════════799if st.session_state.memory:800    with st.expander(f"⚙ ULTRON'S INTELLIGENCE FILE — {len(st.session_state.memory)} ENTRIES"):801        st.markdown('<div class="mem-panel"><div class="mem-title">// SUBJECT PROFILE</div>', unsafe_allow_html=True)802        for f in st.session_state.memory:803            st.markdown(f'<div class="mem-row">▸ {f}</div>', unsafe_allow_html=True)804        st.markdown('</div>', unsafe_allow_html=True)805        if st.button("WIPE INTELLIGENCE FILE", use_container_width=True):806            st.session_state.memory = []807            st.rerun()808