Commit 35d6a54a by wangzhiyang Committed by 胡悦

chore(send_test1.sh): 清理冗余代码并更新测试脚本

修正shebang为更通用的格式,移除DOS换行处理代码,更新使用说明,新增反引号使用提示,移除无用的变量替换逻辑,优化代码缩进与注释
1 parent bc6a112f
#!/bin/bash #!/usr/bin/env bash
# 模拟用户消息发送到 Agent 服务 # 模拟用户消息发送到 Agent 服务
# 用法: ./send_test.sh "你的问题" # 用法: ./send_test1.sh "你的问题"
# 例如: ./send_test.sh "帮我整理上周的会议纪要" # 例如: ./send_test1.sh "帮我整理上周的会议纪要"
#
if grep -q $'\r' "$0" 2>/dev/null; then # 注意:不要用反引号包 URL(例如 `https://...`),反引号在 bash 中会触发命令替换。
if command -v mktemp >/dev/null 2>&1; then # 如果你一定要保留反引号,请用单引号包住整个参数:bash ./send_test1.sh '... `https://...` ...'
_tmp="$(mktemp)"
else
_tmp="/tmp/send_test.$$.sh"
fi
tr -d '\r' < "$0" > "$_tmp" && chmod +x "$_tmp" && exec bash "$_tmp" "$@"
fi
QUERY="${1:-你好,请问你能帮我什么?}" QUERY="${1:-你好,请问你能帮我什么?}"
QUERY="${QUERY//\`/}"
API_URL="${API_URL:-http://localhost:8000/api/v1/chat/completions}" API_URL="${API_URL:-http://localhost:8000/api/v1/chat/completions}"
SESSION_ID="${SESSION_ID:-test_sess_001}" SESSION_ID="${SESSION_ID:-test_sess_001}"
POSITION_CODE="${POSITION_CODE:-conference_assistant}" POSITION_CODE="${POSITION_CODE:-conference_assistant}"
...@@ -139,7 +132,6 @@ HTTP_CODE=$(printf '%s' "${PAYLOAD}" | curl -s -w "\n%{http_code}" -X POST "${AP ...@@ -139,7 +132,6 @@ HTTP_CODE=$(printf '%s' "${PAYLOAD}" | curl -s -w "\n%{http_code}" -X POST "${AP
-H "Content-Type: application/json; charset=utf-8" \ -H "Content-Type: application/json; charset=utf-8" \
--data-binary @-) --data-binary @-)
# 分离 body 和 status code
BODY=$(echo "${HTTP_CODE}" | sed '$d') BODY=$(echo "${HTTP_CODE}" | sed '$d')
STATUS=$(echo "${HTTP_CODE}" | tail -n1) STATUS=$(echo "${HTTP_CODE}" | tail -n1)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!