{"id":708,"date":"2025-11-26T17:32:19","date_gmt":"2025-11-26T22:32:19","guid":{"rendered":"https:\/\/brainwashed.me\/?page_id=708"},"modified":"2025-12-15T11:08:50","modified_gmt":"2025-12-15T16:08:50","slug":"ai-debate","status":"publish","type":"page","link":"https:\/\/brainwashed.me\/index.php\/ai-debate\/","title":{"rendered":"AI Debate"},"content":{"rendered":"\n<div id=\"theme_group\" class=\"wp-block-group hide-frontend is-layout-constrained wp-container-core-group-is-layout-639b5052 wp-block-group-is-layout-constrained\" style=\"padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-a5331a9e wp-block-columns-is-layout-flex\" style=\"padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<h3 class=\"wp-block-heading\" id=\"theme_prompt\"><\/h3>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button is-style-outline is-style-outline--1\" id=\"reset_theme\"><a class=\"wp-block-button__link wp-element-button\">Reset Theme<\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div id=\"claim_group\" class=\"wp-block-group hide-frontend is-layout-constrained wp-container-core-group-is-layout-639b5052 wp-block-group-is-layout-constrained\" style=\"padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-cbbdb216 wp-block-columns-is-layout-flex\" style=\"padding-top:var(--wp--preset--spacing--20);padding-right:0;padding-bottom:var(--wp--preset--spacing--20);padding-left:0\">\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<h6 class=\"wp-block-heading\" id=\"subject_prompt\"><\/h6>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button is-style-outline is-style-outline--2\" id=\"reset_claim\"><a class=\"wp-block-button__link wp-element-button\">Reset Claim<\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-1ec2ec05 wp-block-columns-is-layout-flex\" style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\">\n<div class=\"wp-block-column is-layout-flow wp-container-core-column-is-layout-a77db08e wp-block-column-is-layout-flow\" style=\"flex-basis:50%\" id=\"theme_picker\">\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>AI Debate Theme Selector<\/title>\n    <style>\n        .spinner {\n            display: inline-block;\n            width: 14px;\n            height: 14px;\n            border: 2px solid #ddd;\n            border-top-color: #555;\n            border-radius: 50%;\n            animation: spin 1s linear infinite;\n            vertical-align: middle;\n        }\n        \n        @keyframes spin {\n            to { transform: rotate(360deg); }\n        }\n        \n        .loading-dots::after {\n            content: '';\n            animation: dots 1.5s steps(4, end) infinite;\n        }\n        \n        @keyframes dots {\n            0%, 20% { content: ''; }\n            40% { content: '.'; }\n            60% { content: '..'; }\n            80%, 100% { content: '...'; }\n        }\n    <\/style>\n<\/head>\n<body>\n\n<div id=\"theme_picker\">\n    <div id=\"status\">\n        <span class=\"spinner\"><\/span>\n        <span class=\"loading-dots\">Loading suggestions<\/span>\n    <\/div>\n    <div id=\"choices\"><\/div>\n<\/div>\n\n<script>\nfunction generateUUID() {\n    return 'xxxx-xxxx-4xxx'.replace(\/[x]\/g, () => (Math.random()*16|0).toString(16));\n}\n\nfunction getSessionId() {\n    let sid = sessionStorage.getItem(\"chat_session_id\");\n    if (!sid) { \n        sid = generateUUID(); \n        sessionStorage.setItem(\"chat_session_id\", sid); \n    }\n    return sid;\n}\n\nconst lambdaUrl = \"https:\/\/g5snjmvvfhz4hvqoumd3lryp2q0yugib.lambda-url.us-east-2.on.aws\/\";\nconst themePrompt = \"Suggest 5 diverse and currently debated public themes (mix popular and fringe). Respond ONLY with a Python list like ['Theme one - short desc', 'Theme two - desc', ...]. No extra text.\";\n\nasync function getAgentResponse(prompt) {\n    const controller = new AbortController();\n    const t = setTimeout(() => controller.abort(), 15000);\n    try {\n        const res = await fetch(lambdaUrl, {\n            method: \"POST\",\n            headers: { \"Content-Type\": \"application\/json\" },\n            body: JSON.stringify({ prompt, sessionId: getSessionId() }),\n            signal: controller.signal\n        });\n        clearTimeout(t);\n        if (!res.ok) throw new Error(`HTTP ${res.status}`);\n        const d = await res.json();\n        return d.output || \"\";\n    } catch (e) { \n        clearTimeout(t); \n        throw e; \n    }\n}\n\nasync function fetchOptionsFromServer(prompt) {\n    const raw = await getAgentResponse(prompt);\n    if (!raw) throw new Error(\"Empty response\");\n\n    const m = raw.match(\/\\[[\\s\\S]*\\]\/);\n    if (!m) throw new Error(\"No list found\");\n\n    const cleaned = m[0].replace(\/\\\\n\/g, '').replace(\/['\"]\/g, '\"').trim();\n    const opts = JSON.parse(cleaned);\n    if (!Array.isArray(opts) || opts.length === 0) throw new Error(\"Invalid list\");\n    return opts.map(s => s.trim()).filter(Boolean);\n}\n\nfunction setupOtherOption() {\n    const otherRadio = document.getElementById('otherRadio');\n    const otherText = document.getElementById('otherText');\n    \n    document.querySelectorAll('input[name=\"choice\"]').forEach(r => {\n        r.addEventListener('click', () => {\n            if (r.id === 'otherRadio') {\n                setTimeout(() => otherText.focus(), 50);\n            }\n        });\n    });\n    \n    otherText.addEventListener('focus', () => {\n        otherRadio.checked = true;\n    });\n    \n    otherText.addEventListener('click', () => {\n        otherRadio.checked = true;\n    });\n}\n\nasync function generateThemes() {\n    const status = document.getElementById('status');\n    const container = document.getElementById('choices');\n\n    status.innerHTML = '<span class=\"spinner\"><\/span> <span class=\"loading-dots\">Loading suggestions<\/span>';\n    container.innerHTML = '';\n\n    let options = [];\n    try {\n        options = await fetchOptionsFromServer(themePrompt);\n        status.textContent = \"Choose a theme or write your own:\";\n    } catch (e) {\n        console.error(\"AI error:\", e);\n        status.innerHTML = '<span style=\"color:#c00\">Could not load suggestions \u2014 please type your own theme below<\/span>';\n    }\n\n    options.forEach(opt => {\n        const div = document.createElement('div');\n        const safeOpt = opt.replace(\/\"\/g, '&quot;');\n        div.innerHTML = `<label><input type=\"radio\" name=\"choice\" value=\"${safeOpt}\"> ${opt}<\/label>`;\n        container.appendChild(div);\n    });\n\n    const other = document.createElement('div');\n    other.innerHTML = `<label><input type=\"radio\" name=\"choice\" value=\"other\" id=\"otherRadio\"> Other: <input type=\"text\" id=\"otherText\" placeholder=\"Enter your own theme\"><\/label>`;\n    container.appendChild(other);\n\n    setupOtherOption();\n\n    if (options.length === 0) {\n        setTimeout(() => {\n            document.getElementById('otherRadio').checked = true;\n            document.getElementById('otherText').focus();\n        }, 100);\n    }\n}\n\ndocument.addEventListener('DOMContentLoaded', () => {\n    document.getElementById('reset_theme')?.addEventListener('click', e => {\n        e.preventDefault();\n        generateThemes();\n        document.getElementById('subject_picker')?.classList.add('hide-frontend');\n        document.getElementById('claim_group')?.classList.add('hide-frontend');\n        document.getElementById('theme_picker')?.classList.remove('hide-frontend');\n        document.getElementById('theme_group')?.classList.add('hide-frontend');\n    });\n\n    document.getElementById('submit_theme')?.addEventListener('click', e => {\n        e.preventDefault();\n\n        const checked = document.querySelector('input[name=\"choice\"]:checked');\n        let theme = '';\n\n        if (checked?.value === 'other') {\n            theme = document.getElementById('otherText')?.value.trim();\n            if (!theme) { \n                alert(\"Please enter a theme\"); \n                document.getElementById('otherText').focus();\n                return; \n            }\n        } else if (checked) {\n            theme = checked.value;\n        } else {\n            alert(\"Please select a theme\");\n            return;\n        }\n\n        const header = document.getElementById('theme_prompt');\n        if (header) header.textContent = theme;\n\n        document.getElementById('theme_picker')?.classList.add('hide-frontend');\n        document.getElementById('subject_picker')?.classList.remove('hide-frontend');\n        document.getElementById('theme_group')?.classList.remove('hide-frontend');\n        \n        if (typeof generateSubjects === 'function') {\n            generateSubjects();\n        }\n    });\n\n    generateThemes();\n});\n<\/script>\n<\/body>\n<\/html>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\" id=\"submit_theme\"><a class=\"wp-block-button__link wp-element-button\">Submit Theme<\/a><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column hide-frontend is-layout-flow wp-container-core-column-is-layout-b2a27621 wp-block-column-is-layout-flow\" style=\"padding-top:0;padding-right:0;padding-bottom:0;padding-left:0\" id=\"subject_picker\">\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>AI Debate Subject Selector<\/title>\n    <style>\n        body { font-family: Arial, sans-serif; padding: 20px; line-height: 1.5; }\n        .option { margin: 12px 0; }\n        label { cursor: pointer; display: block; }\n        input[type=\"radio\"] { margin-right: 10px; vertical-align: middle; }\n        #otherText { margin-left: 8px; padding: 6px 10px; width: 340px; font-size: 1em; }\n        .status { margin: 15px 0; color: #555; }\n        .error { color: #c00; font-weight: bold; }\n    <\/style>\n<\/head>\n<body>\n\n<div id=\"subject_picker\">\n    <div id=\"subject_status\" class=\"status\">Loading suggestions\u2026<\/div>\n    <div id=\"subjects\"><\/div>\n<\/div>\n\n<script>\n\n\nasync function generateSubjects() {\n    const status = document.getElementById('subject_status');\n    const container = document.getElementById('subjects');\n    const picker = document.getElementById('subject_picker');\n\tconst theme = document.getElementById('theme_prompt').textContent;\n\t\n\tconst subjectPrompt = `Enumerate 5 diverse statements expressed as claims that tend to be suggested for debates under \"${theme}\" theme. Respond ONLY with a Python list like ['claim one', 'claim two', ...]. No extra text.`;\n\t\n\t\/\/const subjectPrompt = `Offer 5 random colours. Respond ONLY with a Python list like ['colour one', 'colour two', ...]. No extra text.`;\n\t\/\/document.getElementById('subject_prompt').textContent = subjectPrompt;\n\n    picker.style.display = 'block';\n    status.textContent = \"Loading suggestions...\"; \n    container.innerHTML = '';\n\n    let options = [];\n    try {\n        options = await fetchOptionsFromServer(subjectPrompt);\n        status.textContent = \"Choose a subject or write your own:\";\n    } catch (e) {\n        console.error(\"AI error:\", e);\n        status.innerHTML = '<span class=\"error\">Could not load suggestions \u2014 please type your own theme below<\/span>';\n    }\n\n    options.forEach(opt => {\n        const div = document.createElement('div');\n        div.className = 'option';\n        div.innerHTML = `<label><input type=\"radio\" name=\"subject\" value=\"${opt}\">${opt}<\/label>`;\n        container.appendChild(div);\n    });\n\n    const other = document.createElement('div');\n    other.className = 'option';\n    other.innerHTML = `\n        <label>\n            <input type=\"radio\" name=\"subject\" value=\"other\" id=\"otherSubjectRadio\">\n            Other: <input type=\"text\" id=\"otherSubjectText\" placeholder=\"Enter your own subject\">\n        <\/label>`;\n    container.appendChild(other);\n\n    document.querySelectorAll('input[name=\"subject\"]').forEach(r => {\n        r.onclick = () => {\n            const txt = document.getElementById('otherSubjectText');\n            txt.disabled = r.id !== 'otherSubjectRadio';\n            if (r.id === 'otherSubjectRadio') txt.focus();\n        };\n    });\n\n    if (options.length === 0) {\n        setTimeout(() => {\n            document.getElementById('otherSubjectRadio').checked = true;\n            document.getElementById('otherSubjectText').focus();\n        }, 100);\n    }\n}\n\n\/\/ Hook into your real WordPress buttons\ndocument.addEventListener('DOMContentLoaded', () => {\n    \/\/ Refresh subjects\n    document.getElementById('reset_claim')?.addEventListener('click', e => {\n        e.preventDefault();\n        generateSubjects();\n\t\tdocument.getElementById('subject_picker').classList.remove('hide-frontend');\n\t\tdocument.getElementById('claim_group').classList.add('hide-frontend');\n    });\n\n    \/\/ Submit subject (your existing button)\n    document.getElementById('submit_subject')?.addEventListener('click', e => {\n        e.preventDefault();\n\n        const checked = document.querySelector('input[name=\"subject\"]:checked');\n        let subject = '';\n\n        if (checked?.value === 'other') {\n            subject = document.getElementById('otherSubjectText')?.value.trim();\n            if (!subject) { alert(\"Please enter a subject\"); return; }\n        } else if (checked) {\n            subject = checked.value;\n        } else {\n            alert(\"Please select a subject\");\n            return;\n        }\n\n        \/\/ Update heading\n        const header = document.getElementById('subject_prompt');\n        if (header) header.textContent = subject;\n\n        \/\/ Hide subject, disply subject\n\t\tdocument.getElementById('subject_picker').classList.add('hide-frontend');\n\t\tdocument.getElementById('claim_group').classList.remove('hide-frontend');\n    });\n\n\n});\n<\/script>\n<\/body>\n<\/html>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\" id=\"submit_subject\"><a class=\"wp-block-button__link wp-element-button\">Submit Subject<\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>AI Debate Theme Selector Loading suggestions AI Debate Subject Selector Loading suggestions\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-708","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/brainwashed.me\/index.php\/wp-json\/wp\/v2\/pages\/708","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brainwashed.me\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/brainwashed.me\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/brainwashed.me\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/brainwashed.me\/index.php\/wp-json\/wp\/v2\/comments?post=708"}],"version-history":[{"count":129,"href":"https:\/\/brainwashed.me\/index.php\/wp-json\/wp\/v2\/pages\/708\/revisions"}],"predecessor-version":[{"id":886,"href":"https:\/\/brainwashed.me\/index.php\/wp-json\/wp\/v2\/pages\/708\/revisions\/886"}],"wp:attachment":[{"href":"https:\/\/brainwashed.me\/index.php\/wp-json\/wp\/v2\/media?parent=708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}