#!/usr/bin/env bash # Smoke-test AI Insight generate (qwen2.5:3b). Prefer NUC/server, not laptop as proof. # Prerequisites: API + RAG + llm containers up, model pulled, DB migrated. # # export API_BASE=http://127.0.0.1:18000/api/v1 # export API_KEY=... # ./scripts/insight_smoke.sh set -euo pipefail API_BASE="${API_BASE:-http://127.0.0.1:18000/api/v1}" CYCLE_A="${CYCLE_A:-1}" KANDANG_A="${KANDANG_A:-1}" CYCLE_B="${CYCLE_B:-2}" KANDANG_B="${KANDANG_B:-2}" TOPIC="${TOPIC:-eef}" AUTH_HEADER=() if [[ -n "${API_KEY:-}" ]]; then AUTH_HEADER=(-H "X-API-Key: ${API_KEY}") fi ROOT="$(cd "$(dirname "$0")/.." && pwd)" FIXTURE_A="${ROOT}/fixtures/insight/kandang-01.json" FIXTURE_B="${ROOT}/fixtures/insight/kandang-02.json" echo "== Health ==" curl -fsS "${API_BASE}/health/" | head -c 400; echo echo "== RAG health (optional) ==" curl -fsS "${RAG_URL:-http://127.0.0.1:5002}/health" || echo "RAG not up — generate may fall back without SOP chunks" echo "== Ollama tags (optional) ==" curl -fsS "${OLLAMA_URL:-http://127.0.0.1:11434}/api/tags" | head -c 400 || echo "Ollama not up — expect local_fallback" echo gen() { local cycle="$1" kandang="$2" fixture="$3" force="$4" local ctx ctx="$(python - <