mirror of
https://github.com/hanzoai/kai.git
synced 2026-10-17 11:18:06 +00:00
The curl scripts piped any response into jq and exited 0, so a refused key read as success; they now run under set -euo pipefail with --fail-with-body. noul.sh sent "spent 2,000" because the shell expanded $1 inside "$12,000". Go returns errors instead of panicking and gets a go.mod so `go run .` and the CI toolchain find it. Rust reports a missing key as an error rather than a panic and uses rustls, so it builds without system OpenSSL. Both say in one line why they use plain HTTP: go-sdk v8.5.623 refuses a choice question with named criteria, and hanzo-client 8.5.156 has no /v1/decisions. Co-authored-by: Hanzo Dev <[email protected]>
36 lines
1.0 KiB
Bash
Executable File
36 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Score estimation example with Kai / Jev
|
|
# Usage:
|
|
# ./score.sh # uses default model "kai"
|
|
# KAI_MODEL="typesafe/jev-1.13" ./score.sh # uses Jev
|
|
|
|
set -euo pipefail
|
|
|
|
MODEL="${KAI_MODEL:-kai}"
|
|
API_KEY="${HANZO_API_KEY:-${1:-}}"
|
|
|
|
if [ -z "$API_KEY" ]; then
|
|
echo "Error: HANZO_API_KEY is required (set env var or pass as first argument)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
curl -sS --fail-with-body -X POST https://api.hanzo.ai/v1/decisions \
|
|
-H "Authorization: Bearer $API_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"model\": \"$MODEL\",
|
|
\"state\": \"Database connection pool exhausted. 95% of API requests returning 500 status code.\",
|
|
\"questions\": {
|
|
\"severity\": {
|
|
\"type\": \"score\",
|
|
\"instructions\": \"Assess incident severity\",
|
|
\"criteria\": [
|
|
\"low: non-critical glitch\",
|
|
\"medium: minor latency increase\",
|
|
\"high: subset of customers impacted\",
|
|
\"critical: complete production service outage\"
|
|
]
|
|
}
|
|
}
|
|
}" | jq .
|