27 lines
903 B
Python
27 lines
903 B
Python
#!/usr/bin/env python3
|
|
"""测试 Dify dify2openai 代理"""
|
|
import httpx
|
|
import asyncio
|
|
import sys
|
|
|
|
async def test_dify_proxy():
|
|
# Test the dify2openai proxy path
|
|
async with httpx.AsyncClient(timeout=15) as client:
|
|
print("=== Test dify2openai proxy ===")
|
|
url = "http://yw-dify.dc.servyou-it.com/dify2openai/v1/chat/completions"
|
|
headers = {
|
|
"Authorization": "Bearer http://yw-dify.dc.servyou-it.com/v1|app-7jkRkAzvX4QM9v9SM3P8mMEO|Chat",
|
|
"Content-Type": "application/json"
|
|
}
|
|
payload = {
|
|
"model": "Chat",
|
|
"messages": [{"role": "user", "content": "hello"}],
|
|
"stream": False
|
|
}
|
|
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_proxy())
|