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
58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Test Dify API with composite API key format."""
|
|
import json
|
|
import os
|
|
import httpx
|
|
|
|
# The proxy expects composite format: <dify_base_url>|<api_key>|<app_type>
|
|
# Main Dify uses: http://yw-dify.dc.servyou-it.com/v1|app-UaTWYdBSwN6VktKQlbh5YN5H|Chat
|
|
# Approval should use: http://yw-dify.dc.servyou-it.com/v1|app-JWI7u1LTn9XPVe95KL6dHzPx|Chat
|
|
|
|
PROXY_URL = "http://yw-dify.dc.servyou-it.com/dify2openai/v1/chat/completions"
|
|
APPROVAL_KEY_RAW = "app-JWI7u1LTn9XPVe95KL6dHzPx"
|
|
APPROVAL_KEY_COMPOSITE = "http://yw-dify.dc.servyou-it.com/v1|app-JWI7u1LTn9XPVe95KL6dHzPx|Chat"
|
|
|
|
body = {
|
|
"model": "dify",
|
|
"messages": [
|
|
{"role": "user", "content": "我要申请VPN"},
|
|
],
|
|
"temperature": 0,
|
|
}
|
|
|
|
# Test 1: Raw API key (current, failing)
|
|
print("=== Test 1: Raw API key (current) ===")
|
|
headers = {"Authorization": f"Bearer {APPROVAL_KEY_RAW}", "Content-Type": "application/json"}
|
|
try:
|
|
resp = httpx.post(PROXY_URL, json=body, headers=headers, timeout=15.0)
|
|
print(f" HTTP: {resp.status_code}")
|
|
print(f" Body: {resp.text[:300]}")
|
|
except Exception as e:
|
|
print(f" ERROR: {e}")
|
|
|
|
# Test 2: Composite API key
|
|
print("\n=== Test 2: Composite API key ===")
|
|
headers = {"Authorization": f"Bearer {APPROVAL_KEY_COMPOSITE}", "Content-Type": "application/json"}
|
|
try:
|
|
resp = httpx.post(PROXY_URL, json=body, headers=headers, timeout=30.0)
|
|
print(f" HTTP: {resp.status_code}")
|
|
print(f" Body: {resp.text[:500]}")
|
|
if resp.status_code == 200:
|
|
data = resp.json()
|
|
choices = data.get("choices") or []
|
|
if choices:
|
|
content = choices[0].get("message", {}).get("content", "")
|
|
print(f" Content: {content[:300]}")
|
|
try:
|
|
parsed = json.loads(content)
|
|
print(f" Parsed JSON: {json.dumps(parsed, ensure_ascii=False, indent=2)}")
|
|
except:
|
|
print(f" Content is not JSON")
|
|
except Exception as e:
|
|
print(f" ERROR: {e}")
|
|
|
|
# Test 3: Check main Dify key format
|
|
print("\n=== Test 3: Main Dify env vars ===")
|
|
print(f" DIFY_API_KEY = {os.environ.get('DIFY_API_KEY', 'NOT SET')}")
|
|
print(f" DIFY_API_URL = {os.environ.get('DIFY_API_URL', 'NOT SET')}")
|