Files
tazlin 535e4a40c4 tools: track the chat stack drivers, probes and recipes with a usage page
- `tools/chat_stack/` holds the repeatable local-stack tooling: the fake chat worker driver, the logging proxy, the native and SDK round trips, the SSE probe and stream demo, the documentation claim checker, the OpenAI shape probe, the chat worker validator, the coding demo, and the `start_horde.sh` and `start_front.sh` recipes over `tests/run_with_test_stack.sh`
- Every tool takes its endpoints as arguments with environment fallbacks and its key from an argument or `HORDE_API_KEY` (`HORDE_WORKER_API_KEY` for the worker driver, `OPENAI_API_KEY` for the probe), so it does not assume a file path, machine name or key file; outputs go to the working directory or `--out`
- `tools/chat_stack/README.md` lists each tool with every argument, fallback and default, the stack bring-up order and the full-suite command
2026-10-30 23:46:12 -04:00

64 lines
2.1 KiB
Bash

#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Tazlin
#
# SPDX-License-Identifier: AGPL-3.0-or-later
set -euo pipefail
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd -- "$script_dir/../.." && pwd)"
usage() {
cat <<EOF
Usage: bash tools/chat_stack/start_front.sh [options] <run-dir>
Runs the OpenAI-compatible front (python -m horde.oai) in the foreground
against the Horde that start_horde.sh started, from <run-dir>/front/. Run it in
a background shell and wait on GET /v1/models.
Options (each also read from the environment variable shown):
--port P Front port (HORDE_OAI_PORT, 7002)
--listen ADDR Address to bind (HORDE_OAI_LISTEN, 127.0.0.1)
--horde-url URL Horde API root (HORDE_OAI_HORDE_URLS, http://127.0.0.1:7101/api)
--redis-url URL Horde's Redis (HORDE_OAI_REDIS_URL,
redis://127.0.0.1:\$AI_HORDE_TEST_REDIS_PORT/7, port default 46379)
--python PATH Interpreter (CHAT_STACK_PYTHON, the repository's .venv/bin/python)
-h, --help Show this help
Every other HORDE_OAI_* variable in the environment reaches the front unchanged.
EOF
}
port="${HORDE_OAI_PORT:-7002}"
listen="${HORDE_OAI_LISTEN:-127.0.0.1}"
horde_url="${HORDE_OAI_HORDE_URLS:-http://127.0.0.1:7101/api}"
redis_url="${HORDE_OAI_REDIS_URL:-redis://127.0.0.1:${AI_HORDE_TEST_REDIS_PORT:-46379}/7}"
python="${CHAT_STACK_PYTHON:-$repo_root/.venv/bin/python}"
run_dir=""
while [[ $# -gt 0 ]]; do
case "$1" in
--port) port="$2"; shift ;;
--listen) listen="$2"; shift ;;
--horde-url) horde_url="$2"; shift ;;
--redis-url) redis_url="$2"; shift ;;
--python) python="$2"; shift ;;
-h|--help) usage; exit 0 ;;
-*) echo "Unknown option: $1" >&2; usage >&2; exit 1 ;;
*) run_dir="$1" ;;
esac
shift
done
if [[ -z "$run_dir" ]]; then
echo "No run directory given." >&2
usage >&2
exit 1
fi
export HORDE_OAI_PORT="$port" HORDE_OAI_LISTEN="$listen" HORDE_OAI_HORDE_URLS="$horde_url" HORDE_OAI_REDIS_URL="$redis_url"
export PYTHONPATH="$repo_root"
mkdir -p "$run_dir/front"
cd "$run_dir/front"
exec "$python" -m horde.oai