Class: Girb::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/girb/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
11
# File 'lib/girb/configuration.rb', line 7

def initialize
  @provider = nil
  @debug = ENV["GIRB_DEBUG"] == "1"
  @custom_prompt = nil
end

Instance Attribute Details

#custom_promptObject

Returns the value of attribute custom_prompt.



5
6
7
# File 'lib/girb/configuration.rb', line 5

def custom_prompt
  @custom_prompt
end

#debugObject

Returns the value of attribute debug.



5
6
7
# File 'lib/girb/configuration.rb', line 5

def debug
  @debug
end

#providerObject

Returns the value of attribute provider.



5
6
7
# File 'lib/girb/configuration.rb', line 5

def provider
  @provider
end

Instance Method Details

#provider!Object

Get the configured provider, or raise an error if not configured

Raises:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/girb/configuration.rb', line 14

def provider!
  return @provider if @provider

  raise ConfigurationError, <<~MSG
    No LLM provider configured.

    Install a provider gem and set GIRB_PROVIDER environment variable:

      gem install girb-ruby_llm
      export GIRB_PROVIDER=girb-ruby_llm

    Or implement your own provider:

      class MyProvider < Girb::Providers::Base
        def chat(messages:, system_prompt:, tools:)
          # Your implementation
        end
      end

      Girb.configure do |c|
        c.provider = MyProvider.new
      end
  MSG
end