From f6f3f641e17d1e4d80fea834fa6f6f9dd4d261db Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Wed, 22 Apr 2026 16:11:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=AD=A3=20Dify=20=E7=AB=AF?= =?UTF-8?q?=E7=82=B9=E4=B8=BA=20/chat-messages=EF=BC=8C=E8=A1=A5=E5=85=A8?= =?UTF-8?q?=20inputs=20=E5=AD=97=E6=AE=B5=EF=BC=9B=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=9B=B4=E8=BF=9E=E6=B5=8B=E8=AF=95=E9=A1=B5=E5=92=8C=20relay?= =?UTF-8?q?=20=E6=B5=8B=E8=AF=95=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- digital-human.py | 8 +- test-dify.html | 294 +++++++++++++++++++++++++++++++++ test.html | 414 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 714 insertions(+), 2 deletions(-) create mode 100644 test-dify.html create mode 100644 test.html 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 接口,无需中转服务
+ 纯前端 · 不经过任何中转 +快速验证 digital-human-relay 与 Dify 的连通性
+