Files
forgeway/scripts/checks.sh
T
Dolon (Agent)andClaude Fable 5.1 c37e54c5c2 0.2.1: native Ollama dialect on both modes; Home Assistant proven end-to-end
/{mode}/api/{tags,chat,generate,version,show,ps} beside the OpenAI surface.
forge path is a raw proxy (forge is Ollama); the cloud fallback is translated
both ways — NDJSON frames byte-compatible with Ollama's, tool calls round-trip
with synthesised ids, format mapped, think→reasoning_effort (forced to none
with tools: OpenAI rejects the combination on gpt-5.4-mini). Tags never wait
on a model load (HA's list() has a 5 s timeout). local-strict still 503s in
Ollama's error shape; the OpenAI dialect is untouched.

Home Assistant (Lounge, 2026.9.2) configured through its REST config flow and
proven with a real conversation. HA's VLAN cannot reach the k8s ingress, so
it uses forgeway.dmz.lounge.falkvinge.net through the entrance HAProxy
(RFC1918-fenced vhost); the .services. alias needs a pfSense rule from Rick.

22/22 in-cluster checks on both sites. scripts/ha_setup_ollama.py is
idempotent and ends with a real answer; local-smoke-ollama.sh uses the exact
client HA pins.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-18 18:39:31 +00:00

49 lines
4.8 KiB
Bash
Executable File

#!/bin/sh
# Runs INSIDE the cluster, against the live Service and against a throwaway
# instance whose upstream is deliberately dead. Plain POSIX sh + curl only.
GOOD=http://forgeway.forgeway.svc.cluster.local
BAD=http://forgeway-badtest.forgeway.svc.cluster.local
CHAT='{"messages":[{"role":"user","content":"Answer with the single word: PONG"}],"max_tokens":400}'
j() { curl -s -m 180 -o /tmp/b -D /tmp/h -w '%{http_code}' "$@"; }
backend() { grep -i '^x-forgeway-backend:' /tmp/h | tr -d '\r' | awk '{print $2}'; }
content() { sed -n 's/.*"content":"\([^"]*\)".*/\1/p' /tmp/b | head -1 | cut -c1-60; }
echo "1 healthz (forge up) .................. HTTP $(j $GOOD/healthz)"
echo " $(cut -c1-150 /tmp/b)"
echo "2 strict chat (forge up) .............. HTTP $(j -XPOST $GOOD/local-strict/v1/chat/completions -H 'Content-Type: application/json' -d "$CHAT") backend=$(backend)"
echo " content=[$(content)]"
echo "3 optimistic chat (forge up) .......... HTTP $(j -XPOST $GOOD/local-optimistic/v1/chat/completions -H 'Content-Type: application/json' -d "$CHAT") backend=$(backend)"
echo " content=[$(content)]"
echo "4 strict /v1/models .................. HTTP $(j $GOOD/local-strict/v1/models)"
echo " $(cut -c1-140 /tmp/b)"
echo "5 optimistic /v1/models .............. HTTP $(j $GOOD/local-optimistic/v1/models)"
echo " $(cut -c1-220 /tmp/b)"
echo "6 STRICT chat, forge UNAVAILABLE ..... HTTP $(j -XPOST $BAD/local-strict/v1/chat/completions -H 'Content-Type: application/json' -d "$CHAT")"
echo " $(cut -c1-260 /tmp/b)"
echo "7 OPTIMISTIC chat, forge UNAVAILABLE . HTTP $(j -XPOST $BAD/local-optimistic/v1/chat/completions -H 'Content-Type: application/json' -d "$CHAT") backend=$(backend)"
echo " content=[$(content)]"
echo "8 healthz, forge UNAVAILABLE ......... HTTP $(j $BAD/healthz)"
echo " $(cut -c1-150 /tmp/b)"
echo "9 liveness, forge UNAVAILABLE ........ HTTP $(j $BAD/healthz/live)"
echo "10 readiness, forge UNAVAILABLE ....... HTTP $(j $BAD/healthz/ready)"
echo "11 streaming through forge ............ HTTP $(j -XPOST $GOOD/local-strict/v1/chat/completions -H 'Content-Type: application/json' -d '{"messages":[{"role":"user","content":"count to three"}],"max_tokens":200,"stream":true}') sse_chunks=$(grep -c '^data:' /tmp/b)"
echo "12 bare /v1 guard (expect 404) ........ HTTP $(j $GOOD/v1/models)"
echo "13 unknown mode guard (expect 404) .... HTTP $(j $GOOD/local-wishful/v1/models)"
# ---- native Ollama dialect (what Home Assistant's integration speaks) -------
OCHAT='{"model":"gpt-oss:120b","messages":[{"role":"user","content":"Answer with the single word: PONG"}],"stream":false,"think":false,"keep_alive":"5m","options":{"num_ctx":8192}}'
OSTREAM='{"model":"gpt-oss:120b","messages":[{"role":"user","content":"Answer with the single word: PONG"}],"stream":true,"think":false}'
ocontent() { sed -n 's/.*"message": *{[^}]*"content": *"\([^"]*\)".*/\1/p' /tmp/b | head -1 | cut -c1-40; }
ndjson_summary() { printf 'frames=%s content_frames=%s last_done=%s' "$(wc -l < /tmp/b)" "$(grep -c '"content": *"[^"]' /tmp/b)" "$(tail -1 /tmp/b | grep -o '"done": *true' | head -1)"; }
echo "14 ollama /api/tags (forge up) ........ HTTP $(j $GOOD/local-strict/api/tags) $(grep -o '"model":"[^"]*"' /tmp/b | head -1)"
echo "15 ollama /api/chat non-stream (forge) HTTP $(j -XPOST $GOOD/local-strict/api/chat -H 'Content-Type: application/json' -d "$OCHAT") backend=$(backend) content=[$(ocontent)] $(grep -o '"done_reason":"[^"]*"' /tmp/b | head -1)"
echo "16 ollama /api/chat STREAM (forge) .... HTTP $(j -XPOST $GOOD/local-optimistic/api/chat -H 'Content-Type: application/json' -d "$OSTREAM") $(ndjson_summary) ctype=$(grep -i '^content-type' /tmp/h | tr -d '\r' | awk '{print $2}')"
echo "17 ollama /api/version + /api/generate HTTP $(j $GOOD/local-strict/api/version) $(cut -c1-30 /tmp/b) | generate HTTP $(j -XPOST $GOOD/local-strict/api/generate -H 'Content-Type: application/json' -d '{"model":"gpt-oss:120b","prompt":"Answer with the single word: PONG","stream":false,"think":false}') $(grep -o '"response":"[^"]*"' /tmp/b | head -1)"
echo "18 ollama STRICT chat, forge UNAVAIL .. HTTP $(j -XPOST $BAD/local-strict/api/chat -H 'Content-Type: application/json' -d "$OCHAT") $(cut -c1-90 /tmp/b)"
echo "19 ollama OPTIMISTIC chat, UNAVAIL .... HTTP $(j -XPOST $BAD/local-optimistic/api/chat -H 'Content-Type: application/json' -d "$OCHAT") backend=$(backend) content=[$(ocontent)] $(grep -o '"done_reason":"[^"]*"' /tmp/b | head -1)"
echo "20 ollama OPTIMISTIC STREAM, UNAVAIL .. HTTP $(j -XPOST $BAD/local-optimistic/api/chat -H 'Content-Type: application/json' -d "$OSTREAM") backend=$(backend) $(ndjson_summary)"
echo "21 ollama /api/tags, forge UNAVAIL .... HTTP $(j $BAD/local-optimistic/api/tags) (listing, not liveness)"
echo "22 ollama /api/pull guard (expect 400) HTTP $(j -XPOST $GOOD/local-strict/api/pull -H 'Content-Type: application/json' -d '{"model":"llama3"}')"