Class: Ghostest::Config
- Inherits:
-
Object
- Object
- Ghostest::Config
- Includes:
- AttrReader
- Defined in:
- lib/ghostest/config.rb
Defined Under Namespace
Classes: Agent
Instance Attribute Summary collapse
-
#agents ⇒ Object
readonly
Returns the value of attribute agents.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#llm ⇒ Object
readonly
Returns the value of attribute llm.
-
#max_token ⇒ Object
readonly
Returns the value of attribute max_token.
-
#watch_files ⇒ Object
readonly
Returns the value of attribute watch_files.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash, options) ⇒ Config
constructor
A new instance of Config.
- #language_klass ⇒ Object
- #llm_klass ⇒ Object
Constructor Details
#initialize(hash, options) ⇒ Config
Returns a new instance of Config.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ghostest/config.rb', line 6 def initialize(hash, ) @llm = [:llm] @debug = [:debug] @max_token = hash[:max_token] || 32000 @language = (hash[:language] || raise(ConfigError.new("Language is required"))).to_sym @watch_files = hash[:watch_files] || raise(ConfigError.new("Watch files are required")) agents = hash[:agents] || [] @agents = Hash[agents.map { |k, h| [k, Agent.new(k, h, self)] }].with_indifferent_access raise(ConfigError.new("2 Agents are required")) if @agents.size < 2 end |
Instance Attribute Details
#agents ⇒ Object (readonly)
Returns the value of attribute agents.
4 5 6 |
# File 'lib/ghostest/config.rb', line 4 def agents @agents end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
4 5 6 |
# File 'lib/ghostest/config.rb', line 4 def debug @debug end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
4 5 6 |
# File 'lib/ghostest/config.rb', line 4 def language @language end |
#llm ⇒ Object (readonly)
Returns the value of attribute llm.
4 5 6 |
# File 'lib/ghostest/config.rb', line 4 def llm @llm end |
#max_token ⇒ Object (readonly)
Returns the value of attribute max_token.
4 5 6 |
# File 'lib/ghostest/config.rb', line 4 def max_token @max_token end |
#watch_files ⇒ Object (readonly)
Returns the value of attribute watch_files.
4 5 6 |
# File 'lib/ghostest/config.rb', line 4 def watch_files @watch_files end |
Class Method Details
.load(config_path, options) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ghostest/config.rb', line 37 def load(config_path, ) = .with_indifferent_access default_config = parse_config_file(File.('config/ghostest.yml')) if config_path.nil? Config.new(default_config.with_indifferent_access, ) elsif File.exist?(config_path) Config.new(default_config.merge(parse_config_file(config_path)).with_indifferent_access, ) elsif ( = File.(config_path)) && File.exist?() Config.new(default_config.merge(parse_config_file()).with_indifferent_access, ) else raise ConfigError.new("Config file #{config_path} not found") end end |
Instance Method Details
#language_klass ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/ghostest/config.rb', line 27 def language_klass case self.language when :ruby return Ghostest::Languages::Ruby else raise ConfigError.new("Unknown language #{self.language}") end end |
#llm_klass ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/ghostest/config.rb', line 18 def llm_klass case @llm&.to_sym when :azure_open_ai return Llm::Clients::AzureOpenAi else raise ConfigError.new("Unknown llm #{@llm}") end end |