Skip to content

Support LM Studio #517

Description

@LuigiElleBalotta

Problem Statement

At the moment LM Studio is not supported

Proposed Solution

For the quickstart file, my claude code wrote this and this is working:

#!/usr/bin/env bash
set -euo pipefail

# ── OpenJarvis Quickstart (LM Studio edition) ─────────────────────────
# Uses LM Studio instead of Ollama as the local model backend.
# LM Studio exposes an OpenAI-compatible API on port 1234.
#
# Before running this script:
#   1. Open LM Studio and load a model (e.g. Gemma 4 12B)
#   2. Start the server: lms server start
#   3. Run this script
#
# Usage:
#   git clone https://github.com/open-jarvis/OpenJarvis.git
#   cd OpenJarvis
#   ./scripts/quickstart.sh
# ──────────────────────────────────────────────────────────────────────

BLUE='\033[0;34m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
BOLD='\033[1m'

info()  { echo -e "${BLUE}[info]${NC}  $*"; }
ok()    { echo -e "${GREEN}[ok]${NC}    $*"; }
warn()  { echo -e "${YELLOW}[warn]${NC}  $*"; }
fail()  { echo -e "${RED}[fail]${NC}  $*"; exit 1; }

CLEANUP_PIDS=()
cleanup() {
  echo ""
  info "Shutting down..."
  for pid in "${CLEANUP_PIDS[@]}"; do
    kill "$pid" 2>/dev/null || true
  done
  wait 2>/dev/null || true
  ok "Done."
}
trap cleanup EXIT INT TERM

# ── Navigate to repo root ────────────────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$REPO_ROOT"

echo -e "${BOLD}"
echo "  ┌──────────────────────────────────────┐"
echo "  │  OpenJarvis Quickstart (LM Studio)   │"
echo "  └──────────────────────────────────────┘"
echo -e "${NC}"

# ── 1. Check Python ──────────────────────────────────────────────────
info "Checking Python..."
if command -v python &>/dev/null; then
  PY_CMD="python"
elif command -v python3 &>/dev/null; then
  PY_CMD="python3"
else
  fail "Python 3 not found. Install from https://python.org"
fi
PY_VERSION=$("$PY_CMD" -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
PY_MAJOR=$(echo "$PY_VERSION" | cut -d. -f1)
PY_MINOR=$(echo "$PY_VERSION" | cut -d. -f2)
if [ "$PY_MAJOR" -ge 3 ] && [ "$PY_MINOR" -ge 10 ]; then
  ok "Python $PY_VERSION ($PY_CMD)"
else
  fail "Python 3.10+ required (found $PY_VERSION)"
fi

# ── 2. Check / install uv ───────────────────────────────────────────
info "Checking uv..."
if command -v uv &>/dev/null; then
  ok "uv $(uv --version 2>/dev/null | head -1)"
else
  warn "uv not found — installing..."
  curl -LsSf https://astral.sh/uv/install.sh | sh
  export PATH="$HOME/.local/bin:$PATH"
  ok "uv installed"
fi

# ── 3. Check Node.js ────────────────────────────────────────────────
info "Checking Node.js..."
if command -v node &>/dev/null; then
  NODE_VERSION=$(node --version)
  NODE_MAJOR=$(echo "$NODE_VERSION" | sed 's/v//' | cut -d. -f1)
  if [ "$NODE_MAJOR" -ge 18 ]; then
    ok "Node.js $NODE_VERSION"
  else
    fail "Node.js 18+ required (found $NODE_VERSION). Install from https://nodejs.org"
  fi
else
  fail "Node.js not found. Install from https://nodejs.org"
fi

# ── 4. Check LM Studio server ────────────────────────────────────────
# LM Studio exposes an OpenAI-compatible API on port 1234.
# The /v1/models endpoint lists currently loaded models.
LMS_HOST="${LMS_HOST:-localhost}"
LMS_PORT="${LMS_PORT:-1234}"
LMS_BASE_URL="http://${LMS_HOST}:${LMS_PORT}"

info "Checking LM Studio server at ${LMS_BASE_URL}..."
LMS_RESPONSE=$(curl -s --max-time 5 "${LMS_BASE_URL}/v1/models" 2>/dev/null || true)

# LM Studio formats JSON with spaces: "id": "model-name"
# Use grep -o with flexible spacing around the colon
LOADED_MODEL=$(echo "$LMS_RESPONSE" \
  | grep -o '"id"[[:space:]]*:[[:space:]]*"[^"]*"' \
  | head -1 \
  | sed 's/.*"id"[[:space:]]*:[[:space:]]*"\([^"]*\)"/\1/' \
  || true)

if [ -n "$LOADED_MODEL" ]; then
  ok "LM Studio is running — model: ${LOADED_MODEL}"
else
  echo ""
  echo -e "${RED}  LM Studio server not reachable at ${LMS_BASE_URL}${NC}"
  echo ""
  echo "  Please:"
  echo "    1. Open LM Studio"
  echo "    2. Load a model (e.g. Gemma 4 12B)"
  echo "    3. Run:  lms server start"
  echo "    4. Re-run this script"
  echo ""
  echo "  Or set a custom host/port:"
  echo "    LMS_HOST=localhost LMS_PORT=1234 ./scripts/quickstart.sh"
  echo ""
  fail "LM Studio server is not running"
fi

# Expose as env vars so the backend can pick them up
export OPENAI_API_BASE="${LMS_BASE_URL}/v1"
export OPENAI_API_KEY="lm-studio"   # LM Studio doesn't require a real key
export OPENJARVIS_MODEL="${LOADED_MODEL}"

# ── 5. Install Python dependencies ──────────────────────────────────
info "Installing Python dependencies..."
uv sync --extra server --quiet 2>/dev/null || uv sync --extra server
ok "Python dependencies installed"

# ── 6. Build Rust extension ──────────────────────────────────────────
info "Building Rust extension..."
uv run maturin develop -m rust/crates/openjarvis-python/Cargo.toml --quiet 2>/dev/null \
  || uv run maturin develop -m rust/crates/openjarvis-python/Cargo.toml
ok "Rust extension built"

# ── 7. Install frontend dependencies ────────────────────────────────
info "Installing frontend dependencies..."
(cd frontend && npm install --silent 2>/dev/null || npm install)
ok "Frontend dependencies installed"

# ── 8. Start backend ────────────────────────────────────────────────
info "Starting backend API server on port 8000..."
uv run jarvis serve --port 8000 &>/dev/null &
CLEANUP_PIDS+=($!)
sleep 3

if curl -sf http://localhost:8000/health &>/dev/null; then
  ok "Backend running at http://localhost:8000"
else
  warn "Backend may still be starting..."
fi

# ── 9. Start frontend ──────────────────────────────────────────────
info "Starting frontend dev server on port 5173..."
(cd frontend && npm run dev) &>/dev/null &
CLEANUP_PIDS+=($!)
sleep 3
ok "Frontend running at http://localhost:5173"

# ── 10. Open browser ────────────────────────────────────────────────
URL="http://localhost:5173"
info "Opening $URL ..."
case "$(uname -s)" in
  Darwin) open "$URL" ;;
  Linux)  xdg-open "$URL" 2>/dev/null || true ;;
  MINGW*|MSYS*|CYGWIN*) cmd /c start "" "$URL" 2>/dev/null || true ;;
  *)      true ;;
esac

echo ""
echo -e "${GREEN}${BOLD}  OpenJarvis is running!${NC}"
echo ""
echo "  Chat UI:  http://localhost:5173"
echo "  API:      http://localhost:8000"
echo "  Model:    ${OPENJARVIS_MODEL}"
echo "  LM Studio: ${LMS_BASE_URL}"
echo ""
echo "  Press Ctrl+C to stop all services."
echo ""

wait

But in the web interface i get:

Cannot reach OpenJarvis backend

When I open the desktop app it tries to open ollama

Primitive Area

Other

Alternatives Considered

No response

Metadata

Metadata

Assignees

No one assigned

    Fields

    Priority

    P1

    Effort

    M

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions