Files
msh-system/msh_crmeb_22/test-coze-api.sh

105 lines
2.9 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Coze API 测试脚本
# 使用食谱计算器后端接口开发文档中的测试用例数据
# 配置
BASE_URL="http://localhost:20822"
WORKFLOW_ID="1180790412263" # 从 application-sophia.yml 中获取
echo "=========================================="
echo "Coze API 测试脚本"
echo "=========================================="
echo ""
# 检查服务是否运行
echo "1. 检查服务状态..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${BASE_URL}/" 2>&1)
if [ "$HTTP_CODE" = "000" ]; then
echo " ❌ 服务未启动 (端口 20822)"
echo " 请先启动 crmeb-front 服务"
echo ""
echo " 启动命令: cd msh_crmeb_22 && ./mvnw spring-boot:run -pl crmeb-front"
exit 1
else
echo " ✓ 服务已启动"
fi
echo ""
# 测试用例 TC01: 男性透析患者计算
echo "2. 测试用例 TC01: 男性透析患者 - 执行工作流"
echo " 输入数据: gender=male, age=55, height=170, dialysis=true, dryWeight=65.5, creatinine=850"
echo ""
# 工作流请求
echo " 发送请求..."
RESPONSE=$(curl -s -X POST "${BASE_URL}/api/front/coze/workflow/run" \
-H "Content-Type: application/json" \
-d '{
"workflowId": "'${WORKFLOW_ID}'",
"parameters": {
"gender": "male",
"age": 55,
"height": 170,
"dialysis": true,
"dialysisType": "hemodialysis",
"dryWeight": 65.5,
"creatinine": 850
},
"isAsync": false
}')
echo " 响应结果:"
echo "$RESPONSE" | python3 -m json.tool 2>/dev/null || echo "$RESPONSE"
echo ""
# 测试用例 TC02: 女性非透析患者
echo "=========================================="
echo "3. 测试用例 TC02: 女性非透析患者 - 执行工作流"
echo " 输入数据: gender=female, age=48, height=160, dialysis=false, dryWeight=52, creatinine=180"
echo ""
RESPONSE=$(curl -s -X POST "${BASE_URL}/api/front/coze/workflow/run" \
-H "Content-Type: application/json" \
-d '{
"workflowId": "'${WORKFLOW_ID}'",
"parameters": {
"gender": "female",
"age": 48,
"height": 160,
"dialysis": false,
"dryWeight": 52,
"creatinine": 180
},
"isAsync": false
}')
echo " 响应结果:"
echo "$RESPONSE" | python3 -m json.tool 2>/dev/null || echo "$RESPONSE"
echo ""
# 测试 Chat 接口
echo "=========================================="
echo "4. 测试 Chat 接口 (非流式)"
echo ""
RESPONSE=$(curl -s -X POST "${BASE_URL}/api/front/coze/chat" \
-H "Content-Type: application/json" \
-d '{
"botId": "'${WORKFLOW_ID}'",
"userId": "test_user_001",
"stream": false,
"additionalMessages": [
{
"content": "请根据以下信息计算营养方案男性55岁身高170cm血透患者干体重65.5kg血肌酐850μmol/L"
}
]
}')
echo " 响应结果:"
echo "$RESPONSE" | python3 -m json.tool 2>/dev/null || echo "$RESPONSE"
echo ""
echo "=========================================="
echo "测试完成"
echo "=========================================="