feat: External workflow file support with dynamic credential replacement

- Add --workflow-file option to install.sh (default: RAGKI-BotPGVector.json)
- Add --ollama-model option (default: ministral-3:3b)
- Add --embedding-model option (default: nomic-embed-text:latest)
- Update libsupabase.sh to read workflow from external JSON file
- Add Python script for dynamic credential ID replacement in workflow
- Remove id, versionId, meta, tags, active, pinData from imported workflow
- Include RAGKI-BotPGVector.json as default workflow template

Tested successfully on container sb-1769180683
This commit is contained in:
2026-01-23 16:09:45 +01:00
parent f6637080fc
commit 26f5a7370c
3 changed files with 420 additions and 12 deletions

View File

@@ -61,6 +61,9 @@ Domain / n8n options:
--base-domain <domain> (default: userman.de) -> FQDN becomes sb-<unix>.domain
--n8n-owner-email <email> (default: admin@<base-domain>)
--n8n-owner-pass <pass> Optional. If omitted, generated (policy compliant).
--workflow-file <path> Path to n8n workflow JSON file (default: RAGKI-BotPGVector.json)
--ollama-model <model> Ollama chat model (default: ministral-3:3b)
--embedding-model <model> Ollama embedding model (default: nomic-embed-text:latest)
--debug Enable debug mode (show logs on stderr)
--help Show help
@@ -95,11 +98,18 @@ N8N_OWNER_EMAIL=""
N8N_OWNER_PASS=""
POSTGREST_PORT="3000"
# Workflow file (default: RAGKI-BotPGVector.json in script directory)
WORKFLOW_FILE="${SCRIPT_DIR}/RAGKI-BotPGVector.json"
# Ollama API settings (hardcoded for local setup)
OLLAMA_HOST="192.168.45.3"
OLLAMA_PORT="11434"
OLLAMA_URL="http://${OLLAMA_HOST}:${OLLAMA_PORT}"
# Ollama models (can be overridden via CLI)
OLLAMA_MODEL="ministral-3:3b"
EMBEDDING_MODEL="nomic-embed-text:latest"
# ---------------------------
# Arg parsing
# ---------------------------
@@ -119,6 +129,9 @@ while [[ $# -gt 0 ]]; do
--base-domain) BASE_DOMAIN="${2:-}"; shift 2 ;;
--n8n-owner-email) N8N_OWNER_EMAIL="${2:-}"; shift 2 ;;
--n8n-owner-pass) N8N_OWNER_PASS="${2:-}"; shift 2 ;;
--workflow-file) WORKFLOW_FILE="${2:-}"; shift 2 ;;
--ollama-model) OLLAMA_MODEL="${2:-}"; shift 2 ;;
--embedding-model) EMBEDDING_MODEL="${2:-}"; shift 2 ;;
--postgrest-port) POSTGREST_PORT="${2:-}"; shift 2 ;;
--debug) DEBUG="1"; export DEBUG; shift 1 ;;
--help|-h) usage; exit 0 ;;
@@ -145,8 +158,15 @@ if [[ -n "${APT_PROXY}" ]]; then
[[ "${APT_PROXY}" =~ ^http://[^/]+:[0-9]+$ ]] || die "--apt-proxy must look like http://IP:PORT (example: http://192.168.45.2:3142)"
fi
# Validate workflow file exists
if [[ ! -f "${WORKFLOW_FILE}" ]]; then
die "Workflow file not found: ${WORKFLOW_FILE}"
fi
info "Argument-Parsing OK"
info "Workflow file: ${WORKFLOW_FILE}"
info "Ollama model: ${OLLAMA_MODEL}"
info "Embedding model: ${EMBEDDING_MODEL}"
if [[ -n "${APT_PROXY}" ]]; then
info "APT proxy enabled: ${APT_PROXY}"
@@ -602,10 +622,10 @@ info "Chat Webhook URL (intern): ${CHAT_INTERNAL_URL}"
info "Step 10: Setting up n8n credentials and importing RAG workflow..."
# Use the new robust n8n setup function from libsupabase.sh
# Parameters: ctid, email, password, pg_host, pg_port, pg_db, pg_user, pg_pass, ollama_url, ollama_model, embedding_model
# Parameters: ctid, email, password, pg_host, pg_port, pg_db, pg_user, pg_pass, ollama_url, ollama_model, embedding_model, workflow_file
if n8n_setup_rag_workflow "${CTID}" "${N8N_OWNER_EMAIL}" "${N8N_OWNER_PASS}" \
"postgres" "5432" "${PG_DB}" "${PG_USER}" "${PG_PASSWORD}" \
"${OLLAMA_URL}" "llama3.2:3b" "nomic-embed-text:v1.5"; then
"${OLLAMA_URL}" "${OLLAMA_MODEL}" "${EMBEDDING_MODEL}" "${WORKFLOW_FILE}"; then
info "Step 10 OK: n8n RAG workflow setup completed successfully"
else
warn "Step 10: n8n workflow setup failed - manual setup may be required"