7864ab404b
**目录结构**: - scripts/ 顶层运维/工具脚本(20 个) - scripts/deploy/ 一键部署脚本(deploy_*.py / upload_*.py / redeploy.py 等 8 个) - scripts/fix/ 一次性修复脚本(fix_*.py / fix_*.cypher / fix_*.sql 等 9 个) - scripts/debug/ 调试脚本集合(check_*.py/sql、test_*.py、debug_*.py 等 42 个) **ops-tools/jms_ops.py**:jumpserver-ops skill 默认路径修复 - 从 'jumpserver-automation-shareable' 改为 'jumpserver-ops' - 同步更新注释(优先 JP_SKILL_DIR 环境变量) **典型脚本用途**: - scripts/deploy-v1.2.ps1 / -staging.ps1:一键部署 v1.2 到生产 / staging - scripts/init_quick_rules.sql:quick_rules 表初始数据 - scripts/gen_admin_token.py:生成 admin JWT token(调试用) - scripts/build-and-verify.sh:v1.1 实施验证脚本 - scripts/verify_*.sh / .py:API/quick_rules 验证 - scripts/fix/*.py:环境修复(compose、env_key、itsm_bridge 等) 合计 81 文件 + 3317 行 / - 1 行
61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
#!/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())
|