#!/bin/sh # modelgrid chat installer, served at https://install.modelgrid.com # # curl -fsSL https://install.modelgrid.com | bash # # Installs the npm package `modelgrid` for the current user with the npm of the # Node.js on PATH. Without root: when npm's global directory is not writable, # the package goes to ~/.local instead. Nothing is downloaded and run besides # what npm installs. Source: https://code.foss.global/modelgrid.com/landingpage set -eu # modelgrid and FlexHarness declare "engines": { "node": ">=24" } MIN_NODE_MAJOR=24 PACKAGE=modelgrid say() { printf '%s\n' "$*" } fail() { printf 'modelgrid: %s\n' "$*" >&2 exit 1 } if ! command -v node >/dev/null 2>&1; then fail "Node.js ${MIN_NODE_MAJOR} or later is needed and was not found on PATH. Install it from https://nodejs.org (or with your package manager or nvm), then run this again." fi node_version=$(node -p 'process.versions.node' 2>/dev/null || true) node_major=${node_version%%.*} case $node_major in '' | *[!0-9]*) fail "could not read the version of $(command -v node)." ;; esac if [ "$node_major" -lt "$MIN_NODE_MAJOR" ]; then fail "Node.js ${node_version} is too old; modelgrid needs ${MIN_NODE_MAJOR} or later. Update it from https://nodejs.org (or with your package manager or nvm), then run this again." fi if ! command -v npm >/dev/null 2>&1; then fail "npm was not found on PATH next to Node.js ${node_version}. Install npm, then run this again." fi # where `npm install -g` writes: /lib/node_modules and /bin prefix=$(npm prefix -g) target=$prefix/lib/node_modules while [ ! -d "$target" ] && [ "$target" != "/" ]; do target=$(dirname "$target") done if [ -w "$target" ] && { [ ! -d "$prefix/bin" ] || [ -w "$prefix/bin" ]; }; then say "Installing ${PACKAGE} with npm into ${prefix} (Node.js ${node_version})…" npm install -g "$PACKAGE" bin_dir=$prefix/bin else prefix=$HOME/.local say "npm's global directory is not writable; installing ${PACKAGE} into ${prefix} (Node.js ${node_version})…" npm install -g --prefix "$prefix" "$PACKAGE" bin_dir=$prefix/bin fi data_dir=${XDG_DATA_HOME:-$HOME/.local/share}/modelgrid say "" say "modelgrid is installed: ${bin_dir}/modelgrid-chat" case ":${PATH}:" in *":${bin_dir}:"*) ;; *) say "" say "${bin_dir} is not on your PATH. Add it, for example in ~/.profile:" say " export PATH=\"${bin_dir}:\$PATH\"" ;; esac say "" say "Start it on a machine with the AGL inference proxy:" say " modelgrid-chat --agl" say "or against your own OpenAI-compatible servers:" say " MODELGRID_BACKENDS='[{\"name\":\"local\",\"baseUrl\":\"http://localhost:8000/v1\"}]' modelgrid-chat" say "" say "It prints the address to open. Conversations, the access token and the lock live in" say " ${data_dir}" say "(--data or MODELGRID_DATA_DIR choose another directory)."