[split-upload 2/6] f2fd4fa backup via proxy
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env python3
|
||||
"""测试 Dify 原生 API 和 dify2openai 代理"""
|
||||
import httpx
|
||||
import asyncio
|
||||
|
||||
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:
|
||||
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}")
|
||||
|
||||
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())
|
||||
Reference in New Issue
Block a user