Class: FactDb::Config

Inherits:
MywayConfig::Base
  • Object
show all
Defined in:
lib/fact_db/config.rb

Overview

FactDb Configuration using MywayConfig

Schema is defined in lib/fact_db/config/defaults.yml (single source of truth)

All config sections return ConfigSections with symbol keys: FactDb.config.database # => ConfigSection with “postgresql”, host: “localhost”, … FactDb.config.llm # => ConfigSection with :anthropic, model: “claude-…”, … FactDb.config.embedding # => ConfigSection with nil, dimensions: 1536 FactDb.config.ranking # => ConfigSection with 0.25, …

Access values via hash keys or dot notation: FactDb.config.database FactDb.config.database.host FactDb.config.llm FactDb.config.llm.provider

Configuration sources (lowest to highest priority): 1. Bundled defaults: lib/fact_db/config/defaults.yml (ships with gem) 2. XDG user config: - ~/Library/Application Support/fact_db/fact_db.yml (macOS only) - ~/.config/fact_db/fact_db.yml (XDG default) - $XDG_CONFIG_HOME/fact_db/fact_db.yml (if XDG_CONFIG_HOME is set) 3. Project config: ./config/fact_db.yml (environment-specific) 4. Local overrides: ./config/fact_db.local.yml (gitignored) 5. Environment variables (FDB_*) 6. Explicit values passed to configure block

Examples:

Configure with environment variables

export FDB_DATABASE__URL=postgresql://localhost/fact_db_development
export FDB_LLM__PROVIDER=openai
export FDB_LLM__API_KEY=sk-xxx

Configure with Ruby block

FactDb.configure do |config|
  config.llm[:provider] = :openai
  config.llm[:model] = "gpt-4o-mini"
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#embedding_generatorObject

==========================================================================

Callable Accessors (not loaded from config sources)



58
59
60
# File 'lib/fact_db/config.rb', line 58

def embedding_generator
  @embedding_generator
end

#llm_clientObject

==========================================================================

Callable Accessors (not loaded from config sources)



58
59
60
# File 'lib/fact_db/config.rb', line 58

def llm_client
  @llm_client
end

#loggerObject

==========================================================================

Callable Accessors (not loaded from config sources)



58
59
60
# File 'lib/fact_db/config.rb', line 58

def logger
  @logger
end

Class Method Details

.active_xdg_config_fileObject



84
85
86
# File 'lib/fact_db/config.rb', line 84

def self.active_xdg_config_file
  MywayConfig::Loaders::XdgConfigLoader.find_config_file(:fact_db)
end

.xdg_config_fileObject



74
75
76
77
78
79
80
81
82
# File 'lib/fact_db/config.rb', line 74

def self.xdg_config_file
  xdg_home = ENV["XDG_CONFIG_HOME"]
  base = if xdg_home && !xdg_home.empty?
    xdg_home
  else
    File.expand_path("~/.config")
  end
  File.join(base, "fact_db", "fact_db.yml")
end

.xdg_config_pathsObject

==========================================================================

XDG Config Path Helpers



70
71
72
# File 'lib/fact_db/config.rb', line 70

def self.xdg_config_paths
  MywayConfig::Loaders::XdgConfigLoader.config_paths(:fact_db)
end