feat: wire local AI tools to OmniRoute
This commit is contained in:
parent
30dc475e4b
commit
76bcf5edd0
|
|
@ -7,6 +7,8 @@ Run:
|
|||
|
||||
```bash
|
||||
./jeannie deploy-ai-stack
|
||||
./jeannie deploy-hermes
|
||||
./jeannie deploy-ai-tools
|
||||
```
|
||||
|
||||
Runtime split:
|
||||
|
|
@ -30,6 +32,12 @@ Secrets:
|
|||
- Jeannie discovers currently free OpenRouter models and NVIDIA catalog models,
|
||||
creates `agent-fast-free` and `agent-smart-free` OmniRoute combos, and writes
|
||||
`/data/homelab-ai-stack/models.env` for smoke tests and local tools.
|
||||
- `deploy-ai-tools` writes `/data/homelab-ai-stack/ai-tools.env` and creates
|
||||
`jeannie-goose`, `jeannie-holmes`, and `jeannie-hermes` wrappers in
|
||||
`~/.local/bin` so each tool uses the local OmniRoute endpoint and generated
|
||||
free/quota model routes. On fresh hosts, set `LAB_GOOSE_INSTALL_COMMAND`,
|
||||
`LAB_HOLMES_INSTALL_COMMAND`, or `LAB_HERMES_INSTALL_COMMAND` if a CLI is not
|
||||
already available.
|
||||
- Key files and generated env files are ignored by git.
|
||||
|
||||
The container name defaults to `omniroute` so this command owns the same gateway
|
||||
|
|
|
|||
5
jeannie
5
jeannie
|
|
@ -57,6 +57,7 @@ Build And Bootstrap
|
|||
deploy-dex Deploy the Debian-hosted Dex SSO stack.
|
||||
deploy-matrix Deploy the Matrix homeserver (Synapse + Element + Postgres).
|
||||
deploy-ai-stack Deploy the Debian-hosted AI gateway stack.
|
||||
deploy-ai-tools Install/wire local AI CLIs to the AI gateway.
|
||||
deploy-omniroute Deploy the OmniRoute LLM routing gateway.
|
||||
deploy-hermes Deploy the Hermes agent (git-install + venv + gateway service).
|
||||
bootstrap-gitea-repo Ensure the Gitea repo and SSH key wiring exist.
|
||||
|
|
@ -406,6 +407,10 @@ case "${1:-}" in
|
|||
record_change_journal "deploy-ai-stack" "$@"
|
||||
deploy_ai_stack
|
||||
;;
|
||||
deploy-ai-tools)
|
||||
record_change_journal "deploy-ai-tools" "$@"
|
||||
deploy_ai_tools
|
||||
;;
|
||||
deploy-omniroute)
|
||||
record_change_journal "deploy-omniroute" "$@"
|
||||
deploy_omniroute
|
||||
|
|
|
|||
|
|
@ -2507,10 +2507,12 @@ ai_index() {
|
|||
ai_check() {
|
||||
local index_dir="${LAB_AI_KNOWLEDGE_INDEX_DIR:-/data/homelab-ai/index}"
|
||||
local routes_file="${LAB_AI_STACK_MODEL_ROUTES_FILE:-/data/homelab-ai-stack/models.env}"
|
||||
local tools_env_file="${LAB_AI_STACK_TOOLS_ENV_FILE:-/data/homelab-ai-stack/ai-tools.env}"
|
||||
local endpoint="${LAB_AI_GATEWAY_URL:-${LAB_OLLAMA_URL:-http://127.0.0.1:11434}}"
|
||||
local model="${LAB_AI_GATEWAY_MODEL:-qwen2.5:0.5b}"
|
||||
local provider="${LAB_AI_GATEWAY_PROVIDER:-ollama}"
|
||||
local failures=0
|
||||
local tool
|
||||
|
||||
require_debian_server "ai-check"
|
||||
|
||||
|
|
@ -2542,6 +2544,20 @@ ai_check() {
|
|||
printf '%-28s missing - install holmes for Kubernetes triage\n' "holmes k8s triage"
|
||||
fi
|
||||
|
||||
for tool in goose hermes holmes; do
|
||||
if command -v "jeannie-${tool}" >/dev/null 2>&1; then
|
||||
printf '%-28s ok - %s\n' "jeannie-${tool}" "$(command -v "jeannie-${tool}")"
|
||||
else
|
||||
printf '%-28s missing - run ./jeannie deploy-ai-tools\n' "jeannie-${tool}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -s "${tools_env_file}" ]]; then
|
||||
printf '%-28s ok - %s\n' "ai tools env" "${tools_env_file}"
|
||||
else
|
||||
printf '%-28s missing - run ./jeannie deploy-ai-tools\n' "ai tools env"
|
||||
fi
|
||||
|
||||
if [[ -s "${routes_file}" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "${routes_file}"
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ mapping = {
|
|||
"services.ollama.igpu_enable": "LAB_OLLAMA_IGPU_ENABLE",
|
||||
"services.rpi_dns.pihole_web_port": "PIHOLE_WEB_PORT",
|
||||
"services.rpi_dns.uptime_kuma_port": "UPTIME_KUMA_PORT",
|
||||
"services.ai_stack.install_dir": "LAB_AI_STACK_INSTALL_DIR",
|
||||
"services.ai_stack.port": "LAB_OMNIROUTE_PORT",
|
||||
"ai_gateway.provider": "LAB_AI_GATEWAY_PROVIDER",
|
||||
"ai_gateway.enabled": "LAB_BACKSTAGE_BRAIN_ENABLED",
|
||||
"ai_gateway.url": "LAB_AI_GATEWAY_URL",
|
||||
|
|
|
|||
|
|
@ -5399,6 +5399,108 @@ deploy_ai_stack() {
|
|||
else
|
||||
echo "Ollama is not reachable locally; run ./jeannie ollama-setup if local model fallback is required." >&2
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
deploy_ai_tools() {
|
||||
local mode="${LAB_AI_TOOLS_DEPLOY:-true}"
|
||||
local install_dir="${LAB_AI_STACK_INSTALL_DIR:-/data/homelab-ai-stack}"
|
||||
local model_routes_file="${LAB_AI_STACK_MODEL_ROUTES_FILE:-${install_dir}/models.env}"
|
||||
local tools_env_file="${LAB_AI_STACK_TOOLS_ENV_FILE:-${install_dir}/ai-tools.env}"
|
||||
local bin_dir="${LAB_AI_TOOLS_BIN_DIR:-/home/jv/.local/bin}"
|
||||
local port="${LAB_OMNIROUTE_PORT:-20128}"
|
||||
local endpoint="${LAB_AI_GATEWAY_URL:-http://127.0.0.1:${port}/v1}"
|
||||
local api_key="${LAB_AI_GATEWAY_API_KEY:-${OMNIROUTE_API_KEY:-sk_omniroute}}"
|
||||
local fast_model="${LAB_AI_TOOLS_FAST_MODEL:-agent-fast-free}"
|
||||
local smart_model="${LAB_AI_TOOLS_SMART_MODEL:-agent-smart-free}"
|
||||
local missing_tools=()
|
||||
local tool
|
||||
local install_var
|
||||
local install_cmd
|
||||
|
||||
require_debian_server "deploy-ai-tools"
|
||||
|
||||
if disabled_value "${mode}"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -s "${model_routes_file}" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "${model_routes_file}"
|
||||
fast_model="${LAB_AI_TOOLS_FAST_MODEL:-${AI_STACK_AGENT_FAST_MODEL:-${fast_model}}}"
|
||||
smart_model="${LAB_AI_TOOLS_SMART_MODEL:-${AI_STACK_AGENT_SMART_MODEL:-${smart_model}}}"
|
||||
else
|
||||
echo "AI stack model routes are missing at ${model_routes_file}; run ./jeannie deploy-ai-stack first." >&2
|
||||
fi
|
||||
|
||||
echo "Configuring bare-metal AI tools for OmniRoute at ${endpoint}..."
|
||||
install -d -m 0755 "${bin_dir}"
|
||||
sudo install -d -m 0750 -o "$(id -u)" -g "$(id -g)" "${install_dir}"
|
||||
|
||||
for tool in goose holmes hermes; do
|
||||
if command -v "${tool}" >/dev/null 2>&1; then
|
||||
echo "${tool}: present at $(command -v "${tool}")"
|
||||
continue
|
||||
fi
|
||||
|
||||
install_var="LAB_$(printf '%s' "${tool}" | tr '[:lower:]' '[:upper:]')_INSTALL_COMMAND"
|
||||
install_cmd="${!install_var:-}"
|
||||
if [[ -n "${install_cmd}" ]]; then
|
||||
echo "${tool}: installing with ${install_var}..."
|
||||
bash -lc "${install_cmd}"
|
||||
fi
|
||||
|
||||
if ! command -v "${tool}" >/dev/null 2>&1; then
|
||||
missing_tools+=("${tool}")
|
||||
else
|
||||
echo "${tool}: installed at $(command -v "${tool}")"
|
||||
fi
|
||||
done
|
||||
|
||||
if ((${#missing_tools[@]} > 0)); then
|
||||
echo "Missing AI tool(s): ${missing_tools[*]}" >&2
|
||||
echo "Set LAB_GOOSE_INSTALL_COMMAND, LAB_HOLMES_INSTALL_COMMAND, or LAB_HERMES_INSTALL_COMMAND to make fresh installs fully automated." >&2
|
||||
echo "Existing Debian hosts with these tools already installed will pass this phase without manual work." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo tee "${tools_env_file}" >/dev/null <<ENV_EOT
|
||||
# Generated by jeannie deploy-ai-tools. Do not commit.
|
||||
OPENAI_BASE_URL=${endpoint}
|
||||
OPENAI_API_KEY=${api_key}
|
||||
OMNIROUTE_API_KEY=${api_key}
|
||||
LAB_AI_GATEWAY_PROVIDER=omniroute
|
||||
LAB_AI_GATEWAY_URL=${endpoint}
|
||||
LAB_AI_GATEWAY_API_KEY=${api_key}
|
||||
LAB_AI_GATEWAY_MODEL=${smart_model}
|
||||
AI_STACK_AGENT_FAST_MODEL=${fast_model}
|
||||
AI_STACK_AGENT_SMART_MODEL=${smart_model}
|
||||
HOLMES_MODEL=${fast_model}
|
||||
HERMES_OPENAI_BASE_URL=${endpoint}
|
||||
HERMES_OMNIROUTE_API_KEY=${api_key}
|
||||
GOOSE_PROVIDER=openai
|
||||
GOOSE_MODEL=${smart_model}
|
||||
ENV_EOT
|
||||
sudo chmod 600 "${tools_env_file}"
|
||||
|
||||
for tool in goose holmes hermes; do
|
||||
local wrapper="${bin_dir}/jeannie-${tool}"
|
||||
tee "${wrapper}" >/dev/null <<WRAPPER_EOT
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [[ -s "${tools_env_file}" ]]; then
|
||||
set -a
|
||||
# shellcheck disable=SC1091
|
||||
. "${tools_env_file}"
|
||||
set +a
|
||||
fi
|
||||
exec ${tool} "\$@"
|
||||
WRAPPER_EOT
|
||||
chmod 0755 "${wrapper}"
|
||||
done
|
||||
|
||||
echo "AI tools env ready: ${tools_env_file}"
|
||||
echo "Wrappers ready: ${bin_dir}/jeannie-goose, ${bin_dir}/jeannie-holmes, ${bin_dir}/jeannie-hermes"
|
||||
}
|
||||
|
||||
deploy_hermes() {
|
||||
|
|
@ -5407,6 +5509,12 @@ deploy_hermes() {
|
|||
local install_dir="${LAB_HERMES_INSTALL_DIR:-/home/jv/.hermes/hermes-agent}"
|
||||
local uv_bin="${LAB_HERMES_UV_BIN:-/home/jv/.hermes/bin/uv}"
|
||||
local install_docker="${LAB_HERMES_INSTALL_DOCKER:-false}"
|
||||
local ai_stack_dir="${LAB_AI_STACK_INSTALL_DIR:-/data/homelab-ai-stack}"
|
||||
local ai_tools_env_file="${LAB_AI_STACK_TOOLS_ENV_FILE:-${ai_stack_dir}/ai-tools.env}"
|
||||
local ai_model_routes_file="${LAB_AI_STACK_MODEL_ROUTES_FILE:-${ai_stack_dir}/models.env}"
|
||||
local hermes_openai_base_url="${HERMES_OPENAI_BASE_URL:-http://localhost:${LAB_OMNIROUTE_PORT:-20128}/v1}"
|
||||
local hermes_omniroute_api_key="${HERMES_OMNIROUTE_API_KEY:-${LAB_AI_GATEWAY_API_KEY:-sk_omniroute}}"
|
||||
local hermes_model="${HERMES_MODEL:-agent-smart-free}"
|
||||
local value_name
|
||||
local value
|
||||
|
||||
|
|
@ -5457,14 +5565,29 @@ deploy_hermes() {
|
|||
echo "WARNING: could not load hermes secrets; MATRIX_PASSWORD may be blank." >&2
|
||||
fi
|
||||
|
||||
if [[ -s "${ai_model_routes_file}" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "${ai_model_routes_file}"
|
||||
hermes_model="${HERMES_MODEL:-${AI_STACK_AGENT_SMART_MODEL:-${hermes_model}}}"
|
||||
fi
|
||||
if [[ -s "${ai_tools_env_file}" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "${ai_tools_env_file}"
|
||||
hermes_openai_base_url="${HERMES_OPENAI_BASE_URL:-${hermes_openai_base_url}}"
|
||||
hermes_omniroute_api_key="${HERMES_OMNIROUTE_API_KEY:-${OPENAI_API_KEY:-${hermes_omniroute_api_key}}}"
|
||||
hermes_model="${HERMES_MODEL:-${AI_STACK_AGENT_SMART_MODEL:-${hermes_model}}}"
|
||||
fi
|
||||
|
||||
local secrets_file="${hermes_home}/.env"
|
||||
sudo install -d -m 0700 -o "$(id -u)" -g "$(id -g)" "${hermes_home}"
|
||||
if [[ -f "${secrets_file}" ]]; then
|
||||
sudo cp "${secrets_file}" "${secrets_file}.bak-pre-jeannie"
|
||||
fi
|
||||
sudo tee "${secrets_file}" >/dev/null <<ENV_EOT
|
||||
OPENAI_BASE_URL=${HERMES_OPENAI_BASE_URL:-http://localhost:${LAB_OMNIROUTE_PORT:-20128}/v1}
|
||||
HERMES_CUSTOM_LOCALHOST_${LAB_OMNIROUTE_PORT:-20128}_API_KEY=${HERMES_OMNIROUTE_API_KEY:-}
|
||||
OPENAI_BASE_URL=${hermes_openai_base_url}
|
||||
OPENAI_API_KEY=${hermes_omniroute_api_key}
|
||||
HERMES_MODEL=${hermes_model}
|
||||
HERMES_CUSTOM_LOCALHOST_${LAB_OMNIROUTE_PORT:-20128}_API_KEY=${hermes_omniroute_api_key}
|
||||
MATRIX_HOMESERVER=${LAB_MATRIX_SERVER_NAME:-matrix.lab2025.duckdns.org}
|
||||
MATRIX_USER_ID=${HERMES_MATRIX_USER_ID:-@hermes:matrix.lab2025.duckdns.org}
|
||||
MATRIX_PASSWORD=${MATRIX_BOT_PASSWORD:-}
|
||||
|
|
@ -7496,16 +7619,22 @@ spec = {
|
|||
"command": [jeannie, "__up-task", "matrix-deploy"],
|
||||
},
|
||||
{
|
||||
"id": "omniroute-deploy",
|
||||
"title": "OmniRoute deploy",
|
||||
"command": [jeannie, "__up-task", "omniroute-deploy"],
|
||||
"id": "ai-stack-deploy",
|
||||
"title": "AI stack deploy",
|
||||
"command": [jeannie, "__up-task", "ai-stack-deploy"],
|
||||
},
|
||||
{
|
||||
"id": "hermes-deploy",
|
||||
"title": "Hermes deploy",
|
||||
"needs": ["omniroute-deploy", "matrix-deploy"],
|
||||
"needs": ["ai-stack-deploy", "matrix-deploy"],
|
||||
"command": [jeannie, "__up-task", "hermes-deploy"],
|
||||
},
|
||||
{
|
||||
"id": "ai-tools-deploy",
|
||||
"title": "AI tools deploy",
|
||||
"needs": ["ai-stack-deploy", "hermes-deploy"],
|
||||
"command": [jeannie, "__up-task", "ai-tools-deploy"],
|
||||
},
|
||||
{
|
||||
"id": "rpi-services",
|
||||
"title": "RPi services",
|
||||
|
|
@ -7568,6 +7697,12 @@ up_task() {
|
|||
matrix-deploy)
|
||||
deploy_matrix
|
||||
;;
|
||||
ai-stack-deploy)
|
||||
deploy_ai_stack
|
||||
;;
|
||||
ai-tools-deploy)
|
||||
deploy_ai_tools
|
||||
;;
|
||||
omniroute-deploy)
|
||||
deploy_omniroute
|
||||
;;
|
||||
|
|
|
|||
Loading…
Reference in New Issue