-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmoke-test.sh
More file actions
executable file
·34 lines (26 loc) · 1.14 KB
/
smoke-test.sh
File metadata and controls
executable file
·34 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
set -eu
BASE_URL=${BASE_URL:-http://127.0.0.1:4000/v1}
API_KEY=${API_KEY:-${LITELLM_MASTER_KEY:-}}
TIMEOUT_SECONDS=${TIMEOUT_SECONDS:-120}
if [ -z "${API_KEY:-}" ]; then
echo "set API_KEY or LITELLM_MASTER_KEY" >&2
exit 1
fi
tmp_dir=$(mktemp -d)
trap 'rm -rf "$tmp_dir"' EXIT
/usr/bin/curl -fsS \
-H "Authorization: Bearer $API_KEY" \
"$BASE_URL/models" > "$tmp_dir/models.json"
jq -e '.data | length == 1 and .[0].id == "glm-5-nvidia"' "$tmp_dir/models.json" >/dev/null
jq '{data:[.data[] | {id,owned_by}]}' "$tmp_dir/models.json"
cat > "$tmp_dir/payload.json" <<'EOF'
{"model":"glm-5-nvidia","stream":false,"messages":[{"role":"user","content":"Reply with exactly: smoke test ok"}]}
EOF
/usr/bin/curl --max-time "$TIMEOUT_SECONDS" -fsS \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
"$BASE_URL/chat/completions" \
--data-binary @"$tmp_dir/payload.json" > "$tmp_dir/completion.json"
jq -e '.model == "glm-5-nvidia" and .choices[0].message.content == "smoke test ok"' "$tmp_dir/completion.json" >/dev/null
jq '{model,choices:[.choices[] | {message:.message.content}],usage}' "$tmp_dir/completion.json"