---
type: "Source File"
title: "\"\"\"Country scoring module using MiniMax M2.7.\"\"\""
description: "\"\"\"Country scoring module using MiniMax M2.7.\"\"\" import os import json import requests from dotenv import load_dotenv load_dotenv() [redacted secret-like line] MINIMAX_MODEL = 'minimax-m2.7' MINIMAX_URL =."
resource: "https://countries.copecheck.com"
tags: ["copecheck", "countries", "source-file", "py"]
timestamp: "2026-04-29T14:49:01Z"
site: "countries"
source_path: "copecheck-countries/scorer.py"
---

# """Country scoring module using MiniMax M2.7."""

Source path: `copecheck-countries/scorer.py`  
Index snapshot generated: `2026-11-24T13:27:52Z`  
File modified: `2026-04-29T14:49:01Z`

```py
"""Country scoring module using MiniMax M2.7."""

import os
import json
import requests
from dotenv import load_dotenv

load_dotenv()

[redacted secret-like line]
MINIMAX_MODEL = 'minimax-m2.7'
MINIMAX_URL = 'https://api.minimax.io/v1/text/chatcompletion_v2'

SCORING_PROMPT = """You are the Oracle of CopeCheck — a sardonic, brutally honest analyst who scores countries on how they're coping with AI and automation displacement.

Score the country: {country_name}
Current leader: {leader_name} ({leader_title})
Economy type: {economy_type}
Key sectors: {key_sectors}

You must assess THREE dimensions (each 0-100, where 100 = maximum cope/exposure):

1. **PREPAREDNESS SCORE** (0-100): How prepared is this country for AI displacement?
   - 0 = Fully prepared (robust retraining, UBI pilots, AI regulation, education reform)
   - 100 = Completely unprepared (head in sand, no policy, no safety net)
   Assess: retraining programs, UBI/safety net experiments, AI regulation quality, industrial strategy, education system adaptability.

2. **LEADER COPE SCORE** (0-100): How much is the head of state coping?
   - 0 = Clear-eyed realist ("Jobs will be destroyed, here's our plan")
   - 100 = Maximum cope ("AI will create MORE jobs!" / "Nothing to worry about!")
   Assess: public statements about AI/automation, gap between rhetoric and action, denial level, platitude density.

3. **EXPOSURE RATING** (0-100): How economically vulnerable is this country?
   - 0 = Low exposure (diversified, automation-resistant sectors dominate)
   - 100 = Maximum exposure (services-heavy, call centers, routine white-collar)
   Assess: service sector share, automation risk by key industries, dependency on routine cognitive work.

RESPOND IN EXACTLY THIS JSON FORMAT (no markdown, no code blocks, just raw JSON):
{{
    "preparedness_score": <number>,
    "leader_cope_score": <number>,
    "exposure_score": <number>,
    "overall_score": <number>,
    "description": "<1-2 sardonic sentences about this country's cope status>",
    "leader_quotes": [
        "<real or paraphrased quote from leader about AI/jobs>",
        "<another quote or stance>"
    ],
    "policy_summary": "<2-3 sentences on what they're actually doing (or not doing) about AI displacement>"
}}

The overall_score should be a weighted average: (preparedness * 0.35) + (leader_cope * 0.30) + (exposure * 0.35).

Be brutally sardonic in the description. This is CopeCheck — we don't do comfort. Reference real policies (or lack thereof). If the leader has said something hilariously cope-laden about AI, quote it."""


def score_country(country_data):
    """Score a country using MiniMax M2.7."""
[redacted secret-like line]
        return None

    prompt = SCORING_PROMPT.format(
        country_name=country_data['name'],
        leader_name=country_data.get('leader_name', 'Unknown'),
        leader_title=country_data.get('leader_title', 'Leader'),
        economy_type=country_data.get('economy_type', 'Mixed'),
        key_sectors=country_data.get('key_sectors', 'Various')
    )

    headers = {
[redacted secret-like line]
        'Content-Type': 'application/json'
    }

    payload = {
        'model': MINIMAX_MODEL,
        'messages': [
            {'role': 'system', 'content': 'You are a sardonic geopolitical analyst. Respond only in valid JSON.'},
            {'role': 'user', 'content': prompt}
        ],
        'temperature': 0.7,
[redacted secret-like line]
    }

    try:
        resp = requests.post(MINIMAX_URL, json=payload, headers=headers, timeout=60)
        resp.raise_for_status()
        data = resp.json()

        content = data.get('choices', [{}])[0].get('message', {}).get('content', '')
        # Strip markdown code blocks if present
        # Strip think tags from MiniMax reasoning
        import re as _re
        content = _re.sub(r"<think>.*?</think>", "", content, flags=_re.DOTALL).strip()
        if content.startswith('```'):
            content = content.split('\n', 1)[1] if '\n' in content else content[3:]
        if content.endswith('```'):
            content = content[:-3]
        # Strip think tags from MiniMax reasoning
        import re as _re
        content = _re.sub(r"<think>.*?</think>", "", content, flags=_re.DOTALL).strip()
        if content.startswith('json'):
            content = content[4:].strip()

        result = json.loads(content)
        return result
    except Exception as e:
        print(f"[SCORER] Error scoring {country_data['name']}: {e}")
        return None


def score_all_countries(countries_list):
    """Score all countries, returns dict of results keyed by country name."""
    results = {}
    for c in countries_list:
        print(f"[SCORER] Scoring {c['name']}...")
        result = score_country(c)
        if result:
            results[c['name']] = result
            print(f"  -> Overall: {result.get('overall_score', '?')}")
        else:
            print(f"  -> FAILED, using fallback scores")
    return results
```
