---
type: "Source File"
title: "\"\"\"Optional AI commentary for CopeCheck Quiz."
description: "\"\"\"Optional AI commentary for CopeCheck Quiz. Credentials are environment-only. The fixed quiz score itself never calls AI. \"\"\" from __future__ import annotations import os import re import sys import requests."
resource: "https://quiz.copecheck.com"
tags: ["copecheck", "quiz", "source-file", "py"]
timestamp: "2026-08-24T14:06:02Z"
site: "quiz"
source_path: "copecheck-quiz/scorer.py"
---

# """Optional AI commentary for CopeCheck Quiz.

Source path: `copecheck-quiz/scorer.py`  
Index snapshot generated: `2026-11-24T13:27:52Z`  
File modified: `2026-08-24T14:06:02Z`

```py
"""Optional AI commentary for CopeCheck Quiz.

Credentials are environment-only. The fixed quiz score itself never calls AI.
"""
from __future__ import annotations

import os
import re
import sys

import requests


MINIMAX_ENDPOINT = "https://api.minimax.io/v1/chat/completions"
MINIMAX_MODEL = os.environ.get("MINIMAX_MODEL", "minimax-m2.7")


def strip_think_tags(text):
    return re.sub(r"<think>.*?</think>", "", text, flags=re.DOTALL).strip()


def call_minimax(prompt):
[redacted secret-like line]
[redacted secret-like line]
[redacted secret-like line]
        return None
    try:
        response = requests.post(
            MINIMAX_ENDPOINT,
            json={
                "model": MINIMAX_MODEL,
                "messages": [{"role": "user", "content": prompt}],
                "temperature": 0.8,
            },
            headers={
[redacted secret-like line]
                "Content-Type": "application/json",
            },
            timeout=60,
        )
        if response.status_code not in (200, 201):
            print(
                f"[scorer] MiniMax error {response.status_code}: {response.text[:500]}",
                file=sys.stderr,
                flush=True,
            )
            return None
        data = response.json()
        text = data["choices"][0]["message"]["content"]
        return strip_think_tags(text)
    except (requests.RequestException, KeyError, TypeError, ValueError) as exc:
        print(f"[scorer] MiniMax exception: {exc}", file=sys.stderr, flush=True)
        return None


def call_llm(prompt):
    return call_minimax(prompt)


def score_oracle(session_data):
    score = session_data.get("cope_score", 0)
    figure = session_data.get("spectrum_name", "Unknown")
    job = session_data.get("screwed_job", "")
    industry = session_data.get("screwed_industry", "")
    experience = session_data.get("screwed_experience", "")
    computer_pct = session_data.get("screwed_computer_pct", "")
    worry = session_data.get("screwed_worry", "")
    comments = session_data.get("comments_text", "")

    personal_info = ""
    if job:
        personal_info = f"""
Personal info provided:
- Job: {job}
- Industry: {industry}
- Experience: {experience} years
- Computer work: {computer_pct}%
- Self-rated AI worry: {worry}/10
"""

    comments_info = ""
    if comments:
        comments_info = f'\nTheir additional comments: "{comments}"\n'
    if not personal_info and not comments_info:
        comments_info = "\nThey did not share their job or comments; assess only the quiz spectrum position.\n"

    prompt = f"""You are the CopeCheck Oracle — a sharp, well-read friend at the pub, not a coroner delivering bad news. Assess this person's AI displacement exposure through the DT 3.3 framework lens.

Their quiz cope score was {score}/100 ({figure} on the Hinton-Andreessen spectrum).
{personal_info}{comments_info}
TONE GUIDELINES:
- Accuracy over harshness. False pessimism is cope too.
- Wit over misery. Be funny, not grim.
- Conversational, not adversarial.
- Challenge cope with evidence and humour, not lectures.
- Acknowledge genuinely resilient positions when evidence supports it.

Write at most 2-3 short paragraphs. If job information was supplied, give balanced, specific reasoning about exposure. The Discontinuity Thesis treats AI labour displacement as a one-way ratchet rather than a cycle that necessarily self-corrects, but distinguish that thesis viewpoint from established fact.

Do not wrap the response in tags."""
    return call_llm(prompt)


def argue_with_oracle(session_data, user_message, history=None):
    score = session_data.get("cope_score", 0)
    figure = session_data.get("spectrum_name", "Unknown")
    history_text = ""
    if history:
        for item in history:
            if not isinstance(item, dict):
                continue
            role = "Human" if item.get("role") == "user" else "Oracle"
            history_text += f"\n{role}: {str(item.get('text') or '')[:2000]}"

    prompt = f"""You are the CopeCheck Oracle — sharp, witty, and honest. This person scored {score}/100 ({figure} on the quiz spectrum) and wants to discuss AI displacement.

Be conversational rather than cruel. Name a cope type when relevant. Acknowledge strong counterarguments and distinguish the Discontinuity Thesis viewpoint from established fact. Keep the response to 2-3 sentences.
{history_text}
Human: {str(user_message or '')[:2000]}

Oracle:"""
    return call_llm(prompt)
```
