28 lines
927 B
Python
28 lines
927 B
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""测试 Dify API v1 端点"""
|
||
|
|
import httpx
|
||
|
|
import asyncio
|
||
|
|
import sys
|
||
|
|
|
||
|
|
async def test_dify():
|
||
|
|
# Test the base URL
|
||
|
|
async with httpx.AsyncClient(timeout=5) as client:
|
||
|
|
print("=== Test 1: Base URL ===")
|
||
|
|
r = await client.get("http://yw-dify.dc.servyou-it.com/")
|
||
|
|
print(f"Status: {r.status_code}, Location: {r.headers.get('location', 'N/A')}")
|
||
|
|
|
||
|
|
print("\n=== Test 2: API v1/chat-messages ===")
|
||
|
|
url = "http://yw-dify.dc.servyou-it.com/v1/chat-messages"
|
||
|
|
headers = {"Authorization": "Bearer app-7jkRkAzvX4QM9v9SM3P8mMEO"}
|
||
|
|
payload = {
|
||
|
|
"query": "hello",
|
||
|
|
"user": "test",
|
||
|
|
"response_mode": "blocking"
|
||
|
|
}
|
||
|
|
r = await client.post(url, json=payload, headers=headers)
|
||
|
|
print(f"Status: {r.status_code}")
|
||
|
|
print(f"Response: {r.text[:500]}")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
asyncio.run(test_dify())
|