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
80 lines
2.4 KiB
Python
80 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Test Dify API with different model parameter formats."""
|
|
import json
|
|
import httpx
|
|
|
|
BASE_URL = "http://yw-dify.dc.servyou-it.com/dify2openai"
|
|
API_KEY = "app-JWI7u1LTn9XPVe95KL6dHzPx"
|
|
url = f"{BASE_URL.rstrip('/')}/v1/chat/completions"
|
|
|
|
headers = {
|
|
"Authorization": f"Bearer {API_KEY}",
|
|
"Content-Type": "application/json",
|
|
}
|
|
|
|
# Test different model parameter formats
|
|
test_models = [
|
|
"dify",
|
|
"", # empty string
|
|
"gpt-3.5-turbo",
|
|
"deepseek-chat",
|
|
"default",
|
|
]
|
|
|
|
for model in test_models:
|
|
body = {
|
|
"model": model,
|
|
"messages": [
|
|
{"role": "user", "content": "我要申请VPN"},
|
|
],
|
|
"temperature": 0,
|
|
}
|
|
print(f"\n=== model={repr(model)} ===")
|
|
try:
|
|
resp = httpx.post(url, json=body, headers=headers, timeout=15.0)
|
|
print(f" HTTP Status: {resp.status_code}")
|
|
body_text = resp.text[:500]
|
|
print(f" Response: {body_text}")
|
|
except Exception as e:
|
|
print(f" ERROR: {type(e).__name__}: {e}")
|
|
|
|
# Also test without model parameter at all
|
|
print(f"\n=== No model parameter ===")
|
|
body = {
|
|
"messages": [
|
|
{"role": "user", "content": "我要申请VPN"},
|
|
],
|
|
"temperature": 0,
|
|
}
|
|
try:
|
|
resp = httpx.post(url, json=body, headers=headers, timeout=15.0)
|
|
print(f" HTTP Status: {resp.status_code}")
|
|
print(f" Response: {resp.text[:500]}")
|
|
except Exception as e:
|
|
print(f" ERROR: {type(e).__name__}: {e}")
|
|
|
|
# Test with the main AI chat API key to compare
|
|
# First, check what API key the main Dify uses
|
|
print(f"\n=== Check main Dify config ===")
|
|
import os
|
|
main_key = os.environ.get("DIFY_API_KEY", "")
|
|
main_base = os.environ.get("DIFY_BASE_URL", "")
|
|
print(f" DIFY_API_KEY: {main_key[:20]}..." if main_key else " DIFY_API_KEY: not set")
|
|
print(f" DIFY_BASE_URL: {main_base}")
|
|
|
|
if main_key:
|
|
main_url = f"{main_base.rstrip('/')}/v1/chat/completions" if main_base else url
|
|
main_headers = {"Authorization": f"Bearer {main_key}", "Content-Type": "application/json"}
|
|
body = {
|
|
"model": "dify",
|
|
"messages": [{"role": "user", "content": "你好"}],
|
|
"temperature": 0,
|
|
}
|
|
print(f"\n=== Test main Dify API with model='dify' ===")
|
|
try:
|
|
resp = httpx.post(main_url, json=body, headers=main_headers, timeout=15.0)
|
|
print(f" HTTP Status: {resp.status_code}")
|
|
print(f" Response: {resp.text[:500]}")
|
|
except Exception as e:
|
|
print(f" ERROR: {type(e).__name__}: {e}")
|