#!/usr/bin/env python3
"""Quick thinking mode test."""

import os
import sys
import time

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from core.zai_client import ZAiClient


api_key = os.environ.get("ZAI_API_KEY")
if not api_key:
    print("ERROR: ZAI_API_KEY not set")
    sys.exit(1)

print("Testing GLM-4.7-flash thinking modes...\n")

with ZAiClient(api_key, timeout=30.0) as client:
    print("1. Thinking DISABLED:")
    try:
        r = client.chat_completion(
            model="glm-4.7-flash",
            messages=[{"role": "user", "content": "Say 'OK'"}],
            thinking={"type": "disabled"},
            max_tokens=20,
        )
        print(f"   Content: {r.content}")
        print(f"   Reasoning: {r.reasoning_content or 'None'}")
    except Exception as e:
        print(f"   ERROR: {e}")

    time.sleep(2)

    print("\n2. Thinking ENABLED:")
    try:
        r = client.chat_completion(
            model="glm-4.7-flash",
            messages=[{"role": "user", "content": "Say 'OK'"}],
            thinking={"type": "enabled"},
            max_tokens=20,
        )
        print(f"   Content: {r.content}")
        print(f"   Reasoning: {r.reasoning_content or 'None'}")
    except Exception as e:
        print(f"   ERROR: {e}")

print("\nDone.")
