Skip to Content
ContributeBackendUser Settings

User Settings

The User model (see Database Models) stores preferences in a user_settings JSONB column: per-purpose LLM defaults, UI preferences, notifications, localization, and privacy.

Schema

user-settings-schema.json
{
  "version": 1,
  "models": {
    "generation": {
      "model_id": "uuid",
      "fallback_model_id": "uuid",
      "temperature": 0.7,
      "max_tokens": 2000
    },
    "evaluation": {
      "model_id": "uuid",
      "temperature": 0.3
    },
    "execution": {
      "model_id": "uuid"
    },
    "embedding": {
      "model_id": "uuid"
    }
  },
  "ui": {
    "theme": "light",
    "density": "comfortable",
    "sidebar_collapsed": false,
    "default_page_size": 25
  },
  "notifications": {
    "email": {
      "test_run_complete": true
    },
    "in_app": {
      "mentions": true
    }
  },
  "localization": {
    "language": "en",
    "timezone": "UTC",
    "date_format": "YYYY-MM-DD",
    "time_format": "24h"
  },
  "privacy": {
    "show_email": false,
    "show_activity": true
  }
}

Only version and the four models slots (generation, evaluation, execution, embedding) are present by default; other sections are created on first write. The column also holds onboarding progress and a default_project reference.

Usage

Read and write through the user.settings property, which wraps the raw dict in typed accessors and returns None for missing values. update() deep-merges and persists the change onto the model automatically — you still commit the session.

accessing-settings.py
# Read (returns None when unset)
model_id = user.settings.models.generation.model_id
temperature = user.settings.models.generation.temperature
theme = user.settings.ui.theme

# Update (deep merge, auto-assigns user.user_settings)
user.settings.update({
    "models": {"generation": {"model_id": str(new_model.id), "temperature": 0.8}}
})
db.commit()

API

settings-endpoints.http
GET /users/settings

PATCH /users/settings
Content-Type: application/json

{
"models": { "generation": { "model_id": "550e8400-...", "temperature": 0.7 } }
}

PATCH merges partial data into existing settings. Changes to models.embedding are rejected — the embedding model is fixed for a deployment.

Validation

Pydantic schemas in rhesis.backend.app.schemas.user validate updates:

  • LLMModelSettingstemperature in 0.0–2.0, max_tokens > 0
  • UISettingsdefault_page_size in 1–100
  • The top-level UserSettings uses extra="forbid", so unknown keys are rejected