Documentation
¶
Overview ¶
Package config — embedding_check.go
The embedding dimension is wired into migration 011 via store.RunMigrations:
pg.RunMigrations(ctx, migrationsDir, cfg.EmbeddingDim)
RunMigrations detects "011_configurable_embedding_dim.sql" by filename and executes it inside a transaction on a dedicated connection with
SET LOCAL app.embedding_dim = <cfg.EmbeddingDim>
immediately before the DO block. SET LOCAL is transaction-scoped, so the GUC is guaranteed to be visible to current_setting('app.embedding_dim') within that same transaction regardless of pool connection reuse.
This file is intentionally kept as documentation. No code is required here because the wiring lives in store.(*Postgres).RunMigrations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Port string
DatabaseURL string
// Embedding (optional — vector search disabled when EMBEDDING_API_KEY and
// CLIPROXY_AUTH_FILE are both empty; FTS remains the graceful fallback).
//
// Routing decision (issue #34): embeddings use OpenAI directly via a
// dedicated sk- key (EMBEDDING_API_KEY). cliproxy is chat-only — it
// returns 404 on /v1/embeddings and is therefore NOT suitable for this
// path. Setting EMBEDDING_API_KEY disables CLIPROXY_AUTH_FILE for the
// embedding path (apiKey takes priority).
//
// Token resolution order:
// 1. EMBEDDING_API_KEY non-empty → static Bearer token (OpenAI direct)
// 2. CLIPROXY_AUTH_FILE non-empty → CliProxyAPI OAuth token (legacy; chat proxies only)
// 3. Both empty → disabled (FTS-only mode, no embeddings generated)
//
// Default EMBEDDING_API_URL: https://api.openai.com/v1
// Default EMBEDDING_MODEL: text-embedding-3-small
// Default EMBEDDING_DIM: 1536 (matches text-embedding-3-small output)
EmbeddingAPIURL string
// EmbeddingAPIKey is a dedicated OpenAI API key (EMBEDDING_API_KEY env var).
// Use a separate key from any chat/LLM key so embedding costs are tracked
// independently and the key can be rotated without affecting chat traffic.
EmbeddingAPIKey string
EmbeddingModel string
EmbeddingDim int // EMBEDDING_DIM — vector dimension; must match the model output. Default 1536.
CliProxyAuthFile string // CLIPROXY_AUTH_FILE — CliProxyAPI OAuth JSON path (chat proxies only; NOT used for embeddings when EMBEDDING_API_KEY is set)
// EmbeddingProvider selects the embedding backend (EMBEDDING_PROVIDER env var).
// Valid values: "openai" (default), "local" (Ollama-compatible).
EmbeddingProvider string
// Local embedding (Ollama-compatible) — used when EMBEDDING_PROVIDER=local.
//
// LOCAL_EMBEDDING_MODEL: Ollama model name (default "bge-m3").
// LOCAL_EMBEDDING_ENDPOINT: Ollama base URL (no default).
// When empty the local embedder is disabled even if
// EMBEDDING_PROVIDER=local (a warning is logged).
LocalEmbeddingModel string
LocalEmbeddingEndpoint string
// LLM (optional — Discord RAG answer generation; falls back to EmbeddingAPIURL when unset)
// LLMAPIURL: LLM_API_URL env var; defaults to EmbeddingAPIURL with /embeddings → /chat/completions suffix fix.
// LLMAPIKey: LLM_API_KEY env var; defaults to EmbeddingAPIKey.
// LLMAuthFile: LLM_CLIPROXY_AUTH_FILE env var; defaults to CLIPROXY_AUTH_FILE when unset.
// LLMTimeoutSeconds: LLM_TIMEOUT_SECONDS env var; per-request HTTP timeout for LLM calls.
// Default 120 s (generous for local CPU inference). Set higher for slow models
// (e.g. gemma3:4b on Mac mini CPU). Setting 0 falls back to the default.
LLMAPIURL string
LLMAPIKey string
LLMAuthFile string // path to CliProxyAPI OAuth JSON for LLM requests
LLMModel string
LLMMaxTokens int
LLMTemperature float64
LLMTimeoutSeconds int // LLM_TIMEOUT_SECONDS — HTTP client timeout; default 120
// Slack (optional)
SlackBotToken string
SlackTeamID string
// Discord (optional)
DiscordBotToken string
DiscordApplicationID string
DiscordGuildIDs []string
DiscordCollectInterval time.Duration
DiscordMentionResponseEnabled bool
// GitHub (optional)
GitHubToken string
GitHubOrg string
// Google Drive (optional)
GDriveCredentialsJSON string
// Notion (optional)
NotionToken string
// Telegram (optional)
TelegramBotToken string
TelegramChatIDs []int64
// Reranker (optional — cross-encoder post-retrieval reranking disabled when empty)
RerankURL string // RERANKER_URL — Jina-compatible /rerank endpoint base URL
RerankAPIKey string // RERANKER_API_KEY — Bearer token for the reranker API
RerankModel string // RERANKER_MODEL — model identifier sent in the request body
// Alerting (optional — Slack/Discord webhook for eval regression alerts)
AlertWebhookURL string // ALERT_WEBHOOK_URL — Slack-compatible incoming webhook URL
// API authentication (optional — disabled when empty, for dev backward compat)
APIKey string // API_KEY — Bearer token required for /api/v1/* routes
// Filesystem (optional)
FilesystemPath string // FILESYSTEM_PATH — directory to scan
FilesystemEnabled bool // FILESYSTEM_ENABLED — default false
FilesystemExcludeDirs []string // FILESYSTEM_EXCLUDE_DIRS — comma-separated dir names to skip (merged with built-in defaults)
FilesystemExcludeExts []string // FILESYSTEM_EXCLUDE_EXTS — comma-separated file extensions to skip (merged with built-in defaults)
// Secretary SQLite (optional — disabled when empty)
SecretaryDBPath string // SECRETARY_DB_PATH — path to secretary.db (e.g. /data/secretary.db)
// LLM Memory SQLite (optional — disabled when empty)
LLMMemoryDBPath string // LLM_MEMORY_DB_PATH — path to llm-memory.sqlite (e.g. /data/llm-memory.sqlite)
// Gmail (optional — disabled when both credential fields are empty)
// GMAIL_CREDENTIALS_JSON: OAuth2 client credentials JSON string (from Google Cloud Console)
// GMAIL_TOKEN_JSON: OAuth2 access/refresh token JSON string
// GMAIL_QUERY: Gmail search query (default: "-in:spam -in:trash")
GmailCredentialsJSON string
GmailTokenJSON string
GmailQuery string
// Calendar (optional — disabled when both credential fields are empty)
// CALENDAR_CREDENTIALS_JSON: OAuth2 client credentials JSON string
// CALENDAR_TOKEN_JSON: OAuth2 access/refresh token JSON string
// CALENDAR_ID: calendar identifier (default: "primary")
// CALENDAR_LOOKAHEAD_DAYS: days into the future to collect (default: 90)
// CALENDAR_LOOKBEHIND_DAYS: days into the past to collect (default: 30)
CalendarCredentialsJSON string
CalendarTokenJSON string
CalendarID string
CalendarLookaheadDays int
CalendarLookbehindDays int
// SMS + Call Log (optional — disabled when SMSSourceDir is empty)
// SMS_SOURCE_DIR: directory containing SMS Backup & Restore XML exports
// (sms-*.xml and calls-*.xml; latest mtime per prefix is used)
SMSSourceDir string
// Whisper transcription (optional — disabled when WhisperAPIKey is empty)
// WHISPER_API_KEY: OpenAI (or compatible) API key
// WHISPER_API_URL: base URL (default: "https://api.openai.com/v1")
// WHISPER_AUDIO_DIR: directory containing audio files to transcribe
// WHISPER_MODEL: model identifier (default: "whisper-1")
// WHISPER_LANGUAGE: BCP-47 language hint (default: "ko")
WhisperAPIKey string
WhisperAPIURL string
WhisperAudioDir string
WhisperModel string
WhisperLanguage string
// Summarizer
// SummarizerBackfillEnabled controls whether the SummarizerWorker scans for
// pre-existing unsummarized documents (WHERE title_summary IS NULL).
// Default true. Set SUMMARIZER_BACKFILL_ENABLED=false when running a slow
// local LLM to avoid a flood of LLM calls for the pre-existing backlog.
SummarizerBackfillEnabled bool // SUMMARIZER_BACKFILL_ENABLED
// Scheduler
CollectInterval time.Duration
// CollectorInstance is the per-host identifier used to key the
// collector_state watermark table. Defaults to os.Hostname() (or
// "default" when that fails) when COLLECTOR_INSTANCE is unset.
CollectorInstance string
}
Config holds all application configuration loaded from environment variables.
func Load ¶
Load reads configuration from environment variables and returns a Config. Required variables (PORT, DATABASE_URL) fall back to safe defaults for development.
func LoadCollector ¶
LoadCollector reads configuration for the collector daemon. It excludes server-only fields (PORT, API_KEY).