diff --git a/digital-human.py b/digital-human.py index 8dc0e36..35e4723 100644 --- a/digital-human.py +++ b/digital-human.py @@ -162,8 +162,12 @@ async def chat_completions(request: Request): "Content-Type": "application/json", } - # 转发到 Dify - dify_endpoint = f"{DIFY_URL.rstrip('/')}/chat/completions" + # 转发到 Dify(Dify 原生端点 /chat-messages) + # 确保 body 包含 inputs 字段(Dify 应用可能要求此字段) + if "inputs" not in body: + body["inputs"] = {} + + dify_endpoint = f"{DIFY_URL.rstrip('/')}/chat-messages" try: async with httpx.AsyncClient(timeout=60.0) as client: diff --git a/test-dify.html b/test-dify.html new file mode 100644 index 0000000..7b7ef36 --- /dev/null +++ b/test-dify.html @@ -0,0 +1,294 @@ + + + + + + Dify API — 直连测试 + + + +
+ +
+
+

Dify API 直连测试

+

直接在浏览器测试 Dify 接口,无需中转服务

+ 纯前端 · 不经过任何中转 +
+ +
+
+ 尚未测试 +
+ +
接口配置
+ +
+ + + 填 Dify 对外可访问的根地址,末尾不要加斜杠 +
+ +
+ + + 从 Dify 应用 → API 密钥 中复制完整密钥 +
+ +
+ + +
+
+ +
+
响应输出
+
+
+ AI 正在生成回复… +
+
// 响应结果将在此显示
+
+ +
+ + + + diff --git a/test.html b/test.html new file mode 100644 index 0000000..9f1513b --- /dev/null +++ b/test.html @@ -0,0 +1,414 @@ + + + + + + Dify 中转服务 — 测试面板 + + + +
+ +
+
+

Dify 中转服务 — 测试面板

+

快速验证 digital-human-relay 与 Dify 的连通性

+
+ + +
+
+ 尚未测试 +
+ +
中转服务配置
+ +
+ + + 填写 digital-human 中转服务的根地址,末尾不要加斜杠 +
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+ +
+
响应输出
+
+
+ AI 正在生成回复… +
+
// 响应结果将在此显示
+
+ +
+ + + +