35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Test detect-intent API from inside backend container (direct FastAPI)."""
|
|
import json
|
|
import httpx
|
|
|
|
# Backend FastAPI listens on 8000 inside the container
|
|
url = "http://localhost:8000/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},
|
|
timeout=30.0,
|
|
)
|
|
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}")
|