28 lines
793 B
Python
28 lines
793 B
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""测试 Dify API 连接"""
|
||
|
|
import httpx
|
||
|
|
import asyncio
|
||
|
|
import sys
|
||
|
|
|
||
|
|
async def test_dify():
|
||
|
|
url = "http://yw-dify.dc.servyou-it.com/v1/chat-messages"
|
||
|
|
headers = {"Authorization": "Bearer app-7jkRkAzvX4QM9v9SM3P8mMEO"}
|
||
|
|
payload = {
|
||
|
|
"query": "test",
|
||
|
|
"user": "test_user",
|
||
|
|
"response_mode": "blocking"
|
||
|
|
}
|
||
|
|
|
||
|
|
try:
|
||
|
|
async with httpx.AsyncClient(timeout=15) as client:
|
||
|
|
print(f"Testing Dify API: {url}")
|
||
|
|
response = await client.post(url, json=payload, headers=headers)
|
||
|
|
print(f"Status: {response.status_code}")
|
||
|
|
print(f"Response: {response.text[:500]}")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Error: {e}")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
asyncio.run(test_dify())
|