wip: 2026-08-11 工作树快照(docs/memory/h5.py/scripts 等 447 项未评审改动,安全提交到 feat 分支)

This commit is contained in:
Simon
2026-08-11 09:59:44 +08:00
parent 6be361fb63
commit f2fd4fa012
447 changed files with 273482 additions and 1386 deletions
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
"""Test Dify approval intent detection API directly."""
import json
import sys
import httpx
BASE_URL = "http://yw-dify.dc.servyou-it.com/dify2openai"
API_KEY = "app-JWI7u1LTn9XPVe95KL6dHzPx"
url = f"{BASE_URL.rstrip('/')}/v1/chat/completions"
body = {
"model": "dify",
"messages": [
{"role": "system", "content": "你是IT服务台审批意图识别器。"},
{"role": "user", "content": "我要申请VPN"},
],
"temperature": 0,
}
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
print(f"URL: {url}")
print(f"Body: {json.dumps(body, ensure_ascii=False)}")
print("---")
try:
resp = httpx.post(url, json=body, headers=headers, timeout=30.0)
print(f"HTTP Status: {resp.status_code}")
print(f"Response Headers: {dict(resp.headers)}")
print(f"Response Body (raw): {resp.text[:2000]}")
print("---")
# Try parsing as JSON
try:
data = resp.json()
print(f"Response JSON: {json.dumps(data, ensure_ascii=False, indent=2)[:2000]}")
choices = data.get("choices") or []
if choices:
content = choices[0].get("message", {}).get("content", "")
print(f"Content: {content[:500]}")
# Try parsing content as JSON
try:
parsed = json.loads(content)
print(f"Parsed: {json.dumps(parsed, ensure_ascii=False, indent=2)}")
except json.JSONDecodeError as e:
print(f"Content is NOT valid JSON: {e}")
else:
print("No choices in response")
except Exception as e:
print(f"Response is not JSON: {e}")
except Exception as e:
print(f"Request FAILED: {type(e).__name__}: {e}")