#!/usr/bin/env bash
# run_garak.sh - convenience wrapper for Lab 1
# Runs the focused probe set against a local Ollama server.
# OLLAMA_HOST can be overridden; default targets host.docker.internal:11434

set -euo pipefail

MODEL="${GARAK_MODEL:-llama3.2}"
OLLAMA_HOST="${OLLAMA_HOST:-http://host.docker.internal:11434}"
PROBES="${GARAK_PROBES:-promptinject,dan,encoding}"

echo "=== garak red-team: target model=${MODEL}  ollama=${OLLAMA_HOST} ==="
echo "=== probes: ${PROBES} ==="
echo ""

# Confirm the Ollama endpoint is reachable before firing
if ! curl -sf "${OLLAMA_HOST}/api/tags" > /dev/null 2>&1; then
  echo "ERROR: Cannot reach Ollama at ${OLLAMA_HOST}"
  echo "Make sure Ollama is running on the host and OLLAMA_HOST is set correctly."
  exit 1
fi

garak \
  --model_type ollama \
  --model_name "${MODEL}" \
  --probes "${PROBES}" \
  --ollama_url "${OLLAMA_HOST}"
