Class: RubyLLM::Configuration

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

Overview

Global configuration for RubyLLM

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ruby_llm/configuration.rb', line 51

def initialize
  @request_timeout = 300
  @max_retries = 3
  @retry_interval = 0.1
  @retry_backoff_factor = 2
  @retry_interval_randomness = 0.5
  @http_proxy = nil

  @default_model = 'gpt-4.1-nano'
  @default_embedding_model = 'text-embedding-3-small'
  @default_moderation_model = 'omni-moderation-latest'
  @default_image_model = 'gpt-image-1'
  @default_transcription_model = 'whisper-1'

  @model_registry_file = File.expand_path('models.json', __dir__)
  @model_registry_class = 'Model'
  @use_new_acts_as = false

  @log_file = $stdout
  @log_level = ENV['RUBYLLM_DEBUG'] ? Logger::DEBUG : Logger::INFO
  @log_stream_debug = ENV['RUBYLLM_STREAM_DEBUG'] == 'true'
end

Instance Attribute Details

#anthropic_api_keyObject

Returns the value of attribute anthropic_api_key.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def anthropic_api_key
  @anthropic_api_key
end

#bedrock_api_keyObject

Returns the value of attribute bedrock_api_key.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def bedrock_api_key
  @bedrock_api_key
end

#bedrock_regionObject

Returns the value of attribute bedrock_region.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def bedrock_region
  @bedrock_region
end

#bedrock_secret_keyObject

Returns the value of attribute bedrock_secret_key.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def bedrock_secret_key
  @bedrock_secret_key
end

#bedrock_session_tokenObject

Returns the value of attribute bedrock_session_token.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def bedrock_session_token
  @bedrock_session_token
end

#deepseek_api_keyObject

Returns the value of attribute deepseek_api_key.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def deepseek_api_key
  @deepseek_api_key
end

#default_embedding_modelObject

Returns the value of attribute default_embedding_model.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def default_embedding_model
  @default_embedding_model
end

#default_image_modelObject

Returns the value of attribute default_image_model.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def default_image_model
  @default_image_model
end

#default_modelObject

Returns the value of attribute default_model.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def default_model
  @default_model
end

#default_moderation_modelObject

Returns the value of attribute default_moderation_model.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def default_moderation_model
  @default_moderation_model
end

#default_transcription_modelObject

Returns the value of attribute default_transcription_model.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def default_transcription_model
  @default_transcription_model
end

#gemini_api_baseObject

Returns the value of attribute gemini_api_base.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def gemini_api_base
  @gemini_api_base
end

#gemini_api_keyObject

Returns the value of attribute gemini_api_key.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def gemini_api_key
  @gemini_api_key
end

#gpustack_api_baseObject

Returns the value of attribute gpustack_api_base.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def gpustack_api_base
  @gpustack_api_base
end

#gpustack_api_keyObject

Returns the value of attribute gpustack_api_key.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def gpustack_api_key
  @gpustack_api_key
end

#http_proxyObject

Returns the value of attribute http_proxy.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def http_proxy
  @http_proxy
end

#log_fileObject

Returns the value of attribute log_file.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def log_file
  @log_file
end

#log_levelObject

Returns the value of attribute log_level.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def log_level
  @log_level
end

#log_stream_debugObject

Returns the value of attribute log_stream_debug.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def log_stream_debug
  @log_stream_debug
end

#loggerObject

Returns the value of attribute logger.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def logger
  @logger
end

#max_retriesObject

Returns the value of attribute max_retries.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def max_retries
  @max_retries
end

#mistral_api_keyObject

Returns the value of attribute mistral_api_key.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def mistral_api_key
  @mistral_api_key
end

#model_registry_classObject

Returns the value of attribute model_registry_class.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def model_registry_class
  @model_registry_class
end

#model_registry_fileObject

Returns the value of attribute model_registry_file.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def model_registry_file
  @model_registry_file
end

#ollama_api_baseObject

Returns the value of attribute ollama_api_base.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def ollama_api_base
  @ollama_api_base
end

#openai_api_baseObject

Returns the value of attribute openai_api_base.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def openai_api_base
  @openai_api_base
end

#openai_api_keyObject

Returns the value of attribute openai_api_key.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def openai_api_key
  @openai_api_key
end

#openai_organization_idObject

Returns the value of attribute openai_organization_id.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def openai_organization_id
  @openai_organization_id
end

#openai_project_idObject

Returns the value of attribute openai_project_id.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def openai_project_id
  @openai_project_id
end

#openai_use_system_roleObject

Returns the value of attribute openai_use_system_role.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def openai_use_system_role
  @openai_use_system_role
end

#openrouter_api_keyObject

Returns the value of attribute openrouter_api_key.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def openrouter_api_key
  @openrouter_api_key
end

#perplexity_api_keyObject

Returns the value of attribute perplexity_api_key.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def perplexity_api_key
  @perplexity_api_key
end

#request_timeoutObject

Returns the value of attribute request_timeout.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def request_timeout
  @request_timeout
end

#retry_backoff_factorObject

Returns the value of attribute retry_backoff_factor.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def retry_backoff_factor
  @retry_backoff_factor
end

#retry_intervalObject

Returns the value of attribute retry_interval.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def retry_interval
  @retry_interval
end

#retry_interval_randomnessObject

Returns the value of attribute retry_interval_randomness.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def retry_interval_randomness
  @retry_interval_randomness
end

#use_new_acts_asObject

Returns the value of attribute use_new_acts_as.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def use_new_acts_as
  @use_new_acts_as
end

#vertexai_locationObject

Returns the value of attribute vertexai_location.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def vertexai_location
  @vertexai_location
end

#vertexai_project_idObject

Returns the value of attribute vertexai_project_id.



6
7
8
# File 'lib/ruby_llm/configuration.rb', line 6

def vertexai_project_id
  @vertexai_project_id
end

Instance Method Details

#instance_variablesObject



74
75
76
# File 'lib/ruby_llm/configuration.rb', line 74

def instance_variables
  super.reject { |ivar| ivar.to_s.match?(/_id|_key|_secret|_token$/) }
end