Class: SmartBrain::Configuration
- Inherits:
-
Object
- Object
- SmartBrain::Configuration
- Defined in:
- lib/smart_brain/configuration.rb
Constant Summary collapse
- DEFAULT_PATH =
File.('../../config/brain.yml', __dir__)
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #allowed_scope_types ⇒ Object
- #briefing ⇒ Object
- #composition ⇒ Object
- #database_config ⇒ Object
- #fact_check ⇒ Object
- #fts_config ⇒ Object
-
#initialize(raw) ⇒ Configuration
constructor
A new instance of Configuration.
- #kg ⇒ Object
- #lifecycle ⇒ Object
- #llm ⇒ Object
- #llm_provider ⇒ Object
- #observability ⇒ Object
- #policies ⇒ Object
- #retention ⇒ Object
- #retrieval ⇒ Object
- #scopes ⇒ Object
- #storage ⇒ Object
- #storage_backend ⇒ Object
- #tiers ⇒ Object
Constructor Details
#initialize(raw) ⇒ Configuration
Returns a new instance of Configuration.
17 18 19 |
# File 'lib/smart_brain/configuration.rb', line 17 def initialize(raw) @raw = raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
15 16 17 |
# File 'lib/smart_brain/configuration.rb', line 15 def raw @raw end |
Class Method Details
.load(path = nil) ⇒ Object
9 10 11 12 13 |
# File 'lib/smart_brain/configuration.rb', line 9 def self.load(path = nil) file_path = path || DEFAULT_PATH data = File.exist?(file_path) ? YAML.safe_load(File.read(file_path), symbolize_names: true) : {} new(data || {}) end |
Instance Method Details
#allowed_scope_types ⇒ Object
45 46 47 |
# File 'lib/smart_brain/configuration.rb', line 45 def allowed_scope_types scopes.fetch(:allowed_types, %w[global project expert task session]).map(&:to_s) end |
#briefing ⇒ Object
77 78 79 |
# File 'lib/smart_brain/configuration.rb', line 77 def briefing raw.fetch(:briefing, {}) end |
#composition ⇒ Object
33 34 35 |
# File 'lib/smart_brain/configuration.rb', line 33 def composition policies.fetch(:composition, {}) end |
#database_config ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/smart_brain/configuration.rb', line 85 def database_config cfg = (storage.fetch(:database, {}) || {}).dup %i[host port database user password].each do |key| env_key = "SMARTBRAIN_DB_#{key.to_s.upcase}" cfg[key] = ENV[env_key] if ENV.key?(env_key) end cfg end |
#fact_check ⇒ Object
73 74 75 |
# File 'lib/smart_brain/configuration.rb', line 73 def fact_check raw.fetch(:fact_check, {}) end |
#fts_config ⇒ Object
94 95 96 |
# File 'lib/smart_brain/configuration.rb', line 94 def fts_config storage.fetch(:fts_config, nil) || database_config.fetch(:fts_config, 'simple') end |
#kg ⇒ Object
69 70 71 |
# File 'lib/smart_brain/configuration.rb', line 69 def kg raw.fetch(:kg, {}) end |
#lifecycle ⇒ Object
65 66 67 |
# File 'lib/smart_brain/configuration.rb', line 65 def lifecycle raw.fetch(:lifecycle, {}) end |
#llm ⇒ Object
53 54 55 |
# File 'lib/smart_brain/configuration.rb', line 53 def llm raw.fetch(:model_provider, {}) end |
#llm_provider ⇒ Object
57 58 59 |
# File 'lib/smart_brain/configuration.rb', line 57 def llm_provider (ENV['SMARTBRAIN_LLM_PROVIDER'] || llm.fetch(:provider, 'stub')).to_s end |
#observability ⇒ Object
37 38 39 |
# File 'lib/smart_brain/configuration.rb', line 37 def observability policies.fetch(:observability, {}) end |
#policies ⇒ Object
21 22 23 |
# File 'lib/smart_brain/configuration.rb', line 21 def policies raw.fetch(:policies, {}) end |
#retention ⇒ Object
25 26 27 |
# File 'lib/smart_brain/configuration.rb', line 25 def retention policies.fetch(:retention, {}) end |
#retrieval ⇒ Object
29 30 31 |
# File 'lib/smart_brain/configuration.rb', line 29 def retrieval policies.fetch(:retrieval, {}) end |
#scopes ⇒ Object
41 42 43 |
# File 'lib/smart_brain/configuration.rb', line 41 def scopes policies.fetch(:scopes, {}) end |
#storage ⇒ Object
49 50 51 |
# File 'lib/smart_brain/configuration.rb', line 49 def storage raw.fetch(:storage, {}) end |
#storage_backend ⇒ Object
81 82 83 |
# File 'lib/smart_brain/configuration.rb', line 81 def storage_backend (ENV['SMARTBRAIN_BACKEND'] || storage.fetch(:backend, 'memory')).to_s end |
#tiers ⇒ Object
61 62 63 |
# File 'lib/smart_brain/configuration.rb', line 61 def tiers raw.fetch(:tiers, {}) end |