my-homelab-configs/scripts/ask

36 lines
803 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
usage() {
cat <<'EOF'
Usage: ./jeannie ask [--citations] QUESTION...
Search the homelab knowledge index for the closest docs, runbooks, scripts, and
Jeannie commands. Set LAB_AI_ASK_LLM=true to ask Ollama after retrieval.
EOF
}
citations=false
case "${1:-}" in
--citations)
citations=true
shift
;;
""|-h|--help|help)
usage
exit 0
;;
esac
if [ "$citations" = "true" ]; then
exec "${REPO_ROOT}/scripts/query-homelab-ai-index" --citations "$@"
fi
if [ "${LAB_AI_ASK_LLM:-false}" = "true" ]; then
exec "${REPO_ROOT}/scripts/query-homelab-ai-index" --ask "$@"
fi
exec "${REPO_ROOT}/scripts/query-homelab-ai-index" --context-only "$@"