bea288e414
== 已部署上线 (9项) == - 代办事项真实数据源集成 (企微审批API 8bug修复链) - H5/坐席端 Logo样式统一+绿色背景 - 视频引导页修复 (localStorage key v2) - 坐席端 v9 Vue版本修复 (ElMessage._context) - 截图按钮 v10 修复 (getDisplayMedia user gesture) - 扫码样式恢复+H5扫码登录跳转修复 - H5截图快捷键提示 == 代码完成待部署 (3项) == - 知识迭代3Bug修复 (#8 POST端点/#7 MERGE幂等/#6 过期检查) - 会议室预定-小鱼易联终端 (40文件, 40/40测试通过) - IT资产升级审批推送 (asset_service.py) == 需求文档 (2项) == - 坐席端AI辅助消息框-PRD (4项新功能确认) - 坐席端布局优化建议 v2.0 (7天计划) == 新增文档 == - 日报-2026-07-11.md - 知识迭代Bug修复报告-20260711.md - 会议室预定-部署指南.md - CHANGELOG.md 更新 == 测试 == - test_todo_integration.py: 40/40 - test_meetingroom.py: 40/40 - test_bugfix_ki_suggestions.py: 21/21
63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Test Dify native API (not the OpenAI proxy) to see raw response."""
|
|
import json
|
|
import httpx
|
|
|
|
# The composite key format is: <dify_base_url>|<api_key>|<app_type>
|
|
# Dify native API base: http://yw-dify.dc.servyou-it.com/v1
|
|
# Dify app API key: app-JWI7u1LTn9XPVe95KL6dHzPx
|
|
|
|
DIFY_NATIVE_BASE = "http://yw-dify.dc.servyou-it.com/v1"
|
|
API_KEY = "app-JWI7u1LTn9XPVe95KL6dHzPx"
|
|
|
|
# Test 1: Dify native chat-messages API
|
|
url = f"{DIFY_NATIVE_BASE}/chat-messages"
|
|
headers = {
|
|
"Authorization": f"Bearer {API_KEY}",
|
|
"Content-Type": "application/json",
|
|
}
|
|
body = {
|
|
"inputs": {},
|
|
"query": "我要申请VPN",
|
|
"response_mode": "blocking",
|
|
"user": "test_user",
|
|
}
|
|
|
|
print(f"=== Dify Native API: {url} ===")
|
|
try:
|
|
resp = httpx.post(url, json=body, headers=headers, timeout=30.0)
|
|
print(f" HTTP: {resp.status_code}")
|
|
print(f" Headers: {dict(resp.headers)}")
|
|
print(f" Body: {resp.text[:2000]}")
|
|
if resp.status_code == 200:
|
|
data = resp.json()
|
|
print(f"\n Parsed:")
|
|
print(f" answer: {data.get('answer', '')[:500]}")
|
|
print(f" conversation_id: {data.get('conversation_id', '')}")
|
|
print(f" message_id: {data.get('message_id', '')}")
|
|
# Check if answer is JSON
|
|
answer = data.get("answer", "")
|
|
try:
|
|
parsed = json.loads(answer)
|
|
print(f" Parsed JSON: {json.dumps(parsed, ensure_ascii=False, indent=2)}")
|
|
except:
|
|
print(f" Answer is NOT JSON: {answer[:200]}")
|
|
except Exception as e:
|
|
print(f" ERROR: {type(e).__name__}: {e}")
|
|
|
|
# Test 2: Also try /completion-messages (for completion apps)
|
|
url2 = f"{DIFY_NATIVE_BASE}/completion-messages"
|
|
body2 = {
|
|
"inputs": {},
|
|
"query": "我要申请VPN",
|
|
"response_mode": "blocking",
|
|
"user": "test_user",
|
|
}
|
|
print(f"\n=== Dify Completion API: {url2} ===")
|
|
try:
|
|
resp = httpx.post(url2, json=body2, headers=headers, timeout=30.0)
|
|
print(f" HTTP: {resp.status_code}")
|
|
print(f" Body: {resp.text[:1000]}")
|
|
except Exception as e:
|
|
print(f" ERROR: {type(e).__name__}: {e}")
|