Compare commits

...
Author SHA1 Message Date
push-app-to-main[bot] 1419ade972 Add hindsight (ct) 2026-11-29 08:07:38 +00:00
2 changed files with 164 additions and 0 deletions

No files matched your search

+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func"
source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func")
# Copyright (c) 2021-2026 community-scripts ORG
# Author: andy-vdg
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://hindsight.vectorize.io/
APP="Hindsight"
var_tags="${var_tags:-ai;memory;mcp}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_disk="${var_disk:-12}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
#var_arm64="${var_arm64:-no}" # unset = ask the user; set yes/no only when verified
var_unprivileged="${var_unprivileged:-1}"
export var_llm_provider="${var_llm_provider:-}"
export var_llm_api_key="${var_llm_api_key:-}"
export var_llm_model="${var_llm_model:-}"
export var_llm_base_url="${var_llm_base_url:-}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/hindsight ]]; then
msg_error "No Hindsight Installation Found!"
exit
fi
if check_for_gh_release "hindsight" "vectorize-io/hindsight"; then
msg_info "Stopping Hindsight"
systemctl stop hindsight
msg_ok "Stopped Hindsight"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "hindsight" "vectorize-io/hindsight" "tarball"
PYTHON_VERSION="3.11" UV_PROJECT_DIR="/opt/hindsight" setup_uv
msg_info "Updating Python Environment"
cd /opt/hindsight
$STD uv sync --locked --package hindsight-api-slim --extra local-ml
HOME=/opt/hindsight_data $STD /opt/hindsight/.venv/bin/python -c "from sentence_transformers import SentenceTransformer, CrossEncoder; from hindsight_api.config import DEFAULT_EMBEDDINGS_LOCAL_MODEL as E, DEFAULT_RERANKER_LOCAL_MODEL as R; SentenceTransformer(E); CrossEncoder(R)"
if ! grep -q '^HF_HUB_OFFLINE=' /opt/hindsight.env; then
cat <<EOF >>/opt/hindsight.env
HF_HUB_OFFLINE=1
EOF
fi
msg_ok "Updated Python Environment"
msg_info "Starting Hindsight"
systemctl start hindsight
msg_ok "Started Hindsight"
msg_ok "Updated successfully!"
fi
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW}Access the API and its interactive docs using the following URL:${CL}"
echo -e "${GATEWAY}${BGN}http://${IP}:8888/docs${CL}"
echo -e "${INFO}${YW}API key: ~/hindsight.creds (inside the container)${CL}"
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: andy-vdg
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://hindsight.vectorize.io/
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
PG_VERSION="18" PG_MODULES="pgvector" setup_postgresql
PG_DB_NAME="hindsight" PG_DB_USER="hindsight" PG_DB_EXTENSIONS="vector,pg_trgm,btree_gin" setup_postgresql_db
fetch_and_deploy_gh_release "hindsight" "vectorize-io/hindsight" "tarball"
PYTHON_VERSION="3.11" UV_PROJECT_DIR="/opt/hindsight" setup_uv
msg_info "Setting up Python Environment"
cd /opt/hindsight
$STD uv sync --locked --package hindsight-api-slim --extra local-ml
msg_ok "Set up Python Environment"
msg_info "Downloading Embedding and Reranker Models"
mkdir -p /opt/hindsight_data
HOME=/opt/hindsight_data $STD /opt/hindsight/.venv/bin/python -c "from sentence_transformers import SentenceTransformer, CrossEncoder; from hindsight_api.config import DEFAULT_EMBEDDINGS_LOCAL_MODEL as E, DEFAULT_RERANKER_LOCAL_MODEL as R; SentenceTransformer(E); CrossEncoder(R)"
msg_ok "Downloaded Embedding and Reranker Models"
msg_info "Configuring Hindsight"
API_KEY=$(random_password 48)
cat <<EOF >/opt/hindsight.env
HINDSIGHT_API_HOST=0.0.0.0
HINDSIGHT_API_PORT=8888
HINDSIGHT_API_DATABASE_URL=postgresql://${PG_DB_USER}:${PG_DB_PASS}@127.0.0.1:5432/${PG_DB_NAME}
HINDSIGHT_API_TENANT_EXTENSION=hindsight_api.extensions.builtin.tenant:ApiKeyTenantExtension
HINDSIGHT_API_TENANT_API_KEY=${API_KEY}
HINDSIGHT_API_LLM_PROVIDER=${var_llm_provider:-none}
HINDSIGHT_API_LLM_API_KEY=${var_llm_api_key:-}
HINDSIGHT_API_LLM_MODEL=${var_llm_model:-}
HINDSIGHT_API_LLM_BASE_URL=${var_llm_base_url:-}
TRANSFORMERS_VERBOSITY=error
HF_HUB_VERBOSITY=error
TOKENIZERS_PARALLELISM=false
# models are cached at install; online, startup stalls on a slow huggingface.co (vectorize-io/hindsight#6494)
HF_HUB_OFFLINE=1
EOF
sed -i '/=$/d' /opt/hindsight.env
chmod 600 /opt/hindsight.env
cat <<EOF >>~/hindsight.creds
Hindsight API Key: ${API_KEY}
EOF
chmod 600 ~/hindsight.creds
msg_ok "Configured Hindsight"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/hindsight.service
[Unit]
Description=Hindsight API
Wants=network-online.target
After=network-online.target postgresql.service
Requires=postgresql.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/hindsight_data
Environment=HOME=/opt/hindsight_data
Environment=PYTHONUNBUFFERED=1
EnvironmentFile=/opt/hindsight.env
ExecStart=/opt/hindsight/.venv/bin/hindsight-api
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now hindsight
msg_ok "Created Service"
if [[ "${var_llm_provider:-none}" == "none" ]]; then
msg_warn "No LLM configured: Hindsight stores plain chunks only. Set HINDSIGHT_API_LLM_PROVIDER and its key in /opt/hindsight.env, then run systemctl restart hindsight"
fi
motd_ssh
customize
cleanup_lxc