#!/usr/bin/env python3 """Test the approval detect-intent API endpoint.""" import json import httpx # Test the API endpoint from inside the container url = "https://localhost/api/approval/detect-intent" test_messages = [ "我要申请VPN", "我的电脑坏了", "我要申请办公用品", "你好,今天天气怎么样?", ] for msg in test_messages: print(f"\n=== Testing: {msg} ===") try: resp = httpx.post( url, json={"text": msg}, headers={"Content-Type": "application/json"}, timeout=30.0, verify=False, # self-signed cert ) print(f" HTTP: {resp.status_code}") print(f" Response: {resp.text[:500]}") if resp.status_code == 200: data = resp.json() result = data.get("data", data) print(f" is_approval: {result.get('is_approval_request')}") print(f" confidence: {result.get('confidence')}") print(f" type: {result.get('approval_type')}") print(f" source: {result.get('source')}") except Exception as e: print(f" ERROR: {type(e).__name__}: {e}")