#!/usr/bin/env bash
set -euo pipefail

png_path="${1:?png_path missing}"
meta_path="${2:?meta_path missing}"
content_path="${3:-}"

echo "Saved PNG:  ${png_path}"
echo "Saved META: ${meta_path}"
if [[ -n "${content_path}" ]]; then
  echo "Saved CONTENT: ${content_path}"
fi

if [[ -n "${OPENAI_API_KEY:-}" ]] || [[ -f ".env" ]]; then
  python3 scripts/ai_prepare_responses.py "$png_path" "$meta_path" "${content_path}"
else
  echo "OPENAI_API_KEY not set (and no .env). Skipping OpenAI step."
fi
