Files
wecom_it_smart_desk/scripts/debug/test_dify_internal.py
T

40 lines
1.2 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
"""测试内部网络 Dify 服务"""
import httpx
import asyncio
async def test_internal():
async with httpx.AsyncClient(timeout=10) as client:
# 测试 RAGFlow (有 Dify API)
print("=== RAGFlow 8080 (Dify API) ===")
try:
r = await client.post(
"http://10.80.0.85:8080/v1/chat-messages",
json={"query": "hello", "user": "test"},
headers={"Content-Type": "application/json"}
)
print(f"Status: {r.status_code}")
print(f"Response: {r.text[:200]}")
except Exception as e:
print(f"Error: {e}")
print()
# 测试内部 Dify 服务 (尝试常见内网地址)
print("=== Try Internal Dify Services ===")
candidates = [
"http://10.80.0.85:8081",
"http://10.80.0.86:8080",
"http://dify:8080",
"http://dify:80",
]
for url in candidates:
try:
r = await client.get(url)
print(f"{url}: {r.status_code}")
except Exception as e:
print(f"{url}: FAIL - {type(e).__name__}")
if __name__ == "__main__":
asyncio.run(test_internal())