P0-1: 删除 docker-compose-override.yml + deploy-server 两份 workers=2→1(预防性修复,服务器根 compose 已是 workers=1)

This commit is contained in:
Simon
2026-07-17 23:16:40 +08:00
parent 3ed86d5fb3
commit 939de70e48
11412 changed files with 2257596 additions and 145 deletions
+55 -57
View File
@@ -1,62 +1,60 @@
#!/usr/bin/env python3
"""Test Dify native API (not the OpenAI proxy) to see raw response."""
import json
"""测试 Dify 原生 API 和 dify2openai 代理"""
import httpx
import asyncio
# 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", "")
async def test_dify():
async with httpx.AsyncClient(timeout=30) as client:
# 1. 测试原生 API 路径
print("=== Test 1: Dify Native API (v1/chat-messages) ===")
url1 = "http://yw-dify.dc.servyou-it.com/v1/chat-messages"
headers1 = {
"Authorization": "Bearer app-7jkRkAzvX4QM9v9SM3P8mMEO",
"Content-Type": "application/json"
}
payload1 = {
"inputs": {"user_query": "hello"},
"query": "hello",
"response_mode": "blocking",
"user": "test-user-001"
}
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}")
r1 = await client.post(url1, json=payload1, headers=headers1)
print(f"Status: {r1.status_code}")
print(f"Response: {r1.text[:300]}")
except Exception as e:
print(f"Error: {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}")
print()
# 2. 测试 dify2openai 代理路径
print("=== Test 2: dify2openai Proxy ===")
url2 = "http://yw-dify.dc.servyou-it.com/dify2openai/v1/chat/completions"
headers2 = {
"Authorization": "Bearer http://yw-dify.dc.servyou-it.com/v1|app-7jkRkAzvX4QM9v9SM3P8mMEO|Chat",
"Content-Type": "application/json"
}
payload2 = {
"model": "Chat",
"messages": [{"role": "user", "content": "hello"}],
"stream": False
}
try:
r2 = await client.post(url2, json=payload2, headers=headers2)
print(f"Status: {r2.status_code}")
print(f"Response: {r2.text[:300]}")
except Exception as e:
print(f"Error: {e}")
print()
# 3. 测试 Dify 健康检查
print("=== Test 3: Dify Health Check ===")
try:
r3 = await client.get("http://yw-dify.dc.servyou-it.com/")
print(f"Status: {r3.status_code}")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
asyncio.run(test_dify())