Class: RCrewAI::Configuration
- Inherits:
-
Object
- Object
- RCrewAI::Configuration
- Defined in:
- lib/rcrewai/configuration.rb
Instance Attribute Summary collapse
-
#anthropic_api_key ⇒ Object
Returns the value of attribute anthropic_api_key.
-
#anthropic_model ⇒ Object
Returns the value of attribute anthropic_model.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#azure_api_key ⇒ Object
Returns the value of attribute azure_api_key.
-
#azure_model ⇒ Object
Returns the value of attribute azure_model.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#deployment_name ⇒ Object
Returns the value of attribute deployment_name.
-
#google_api_key ⇒ Object
Returns the value of attribute google_api_key.
-
#google_model ⇒ Object
Returns the value of attribute google_model.
-
#llm_provider ⇒ Object
Returns the value of attribute llm_provider.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#max_tokens ⇒ Object
Returns the value of attribute max_tokens.
-
#model ⇒ Object
Returns the value of attribute model.
-
#ollama_native_tools ⇒ Object
Returns the value of attribute ollama_native_tools.
-
#openai_api_key ⇒ Object
Returns the value of attribute openai_api_key.
-
#openai_model ⇒ Object
Returns the value of attribute openai_model.
-
#pricing ⇒ Object
Returns the value of attribute pricing.
-
#temperature ⇒ Object
Returns the value of attribute temperature.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #provider_supported?(provider) ⇒ Boolean
- #supported_providers ⇒ Object
- #validate! ⇒ Object
-
#with_overrides(provider: nil, model: nil, api_key: nil, temperature: nil) ⇒ Object
Returns a copy of this configuration with the given per-agent overrides applied.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rcrewai/configuration.rb', line 11 def initialize @llm_provider = :openai @model = 'gpt-4' @temperature = 0.1 @max_tokens = 4000 @timeout = 120 # Default models for each provider @openai_model = 'gpt-4' @anthropic_model = 'claude-3-sonnet-20240229' @google_model = 'gemini-pro' @azure_model = 'gpt-4' @pricing = nil @ollama_native_tools = nil @log_level = :info # Load from environment variables load_from_env end |
Instance Attribute Details
#anthropic_api_key ⇒ Object
Returns the value of attribute anthropic_api_key.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def anthropic_api_key @anthropic_api_key end |
#anthropic_model ⇒ Object
Returns the value of attribute anthropic_model.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def anthropic_model @anthropic_model end |
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def api_key @api_key end |
#api_version ⇒ Object
Returns the value of attribute api_version.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def api_version @api_version end |
#azure_api_key ⇒ Object
Returns the value of attribute azure_api_key.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def azure_api_key @azure_api_key end |
#azure_model ⇒ Object
Returns the value of attribute azure_model.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def azure_model @azure_model end |
#base_url ⇒ Object
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def base_url @base_url end |
#deployment_name ⇒ Object
Returns the value of attribute deployment_name.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def deployment_name @deployment_name end |
#google_api_key ⇒ Object
Returns the value of attribute google_api_key.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def google_api_key @google_api_key end |
#google_model ⇒ Object
Returns the value of attribute google_model.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def google_model @google_model end |
#llm_provider ⇒ Object
Returns the value of attribute llm_provider.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def llm_provider @llm_provider end |
#log_level ⇒ Object
Returns the value of attribute log_level.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def log_level @log_level end |
#max_tokens ⇒ Object
Returns the value of attribute max_tokens.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def max_tokens @max_tokens end |
#model ⇒ Object
Returns the value of attribute model.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def model @model end |
#ollama_native_tools ⇒ Object
Returns the value of attribute ollama_native_tools.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def ollama_native_tools @ollama_native_tools end |
#openai_api_key ⇒ Object
Returns the value of attribute openai_api_key.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def openai_api_key @openai_api_key end |
#openai_model ⇒ Object
Returns the value of attribute openai_model.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def openai_model @openai_model end |
#pricing ⇒ Object
Returns the value of attribute pricing.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def pricing @pricing end |
#temperature ⇒ Object
Returns the value of attribute temperature.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def temperature @temperature end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/rcrewai/configuration.rb', line 5 def timeout @timeout end |
Instance Method Details
#provider_supported?(provider) ⇒ Boolean
92 93 94 |
# File 'lib/rcrewai/configuration.rb', line 92 def provider_supported?(provider) supported_providers.include?(provider.to_sym) end |
#supported_providers ⇒ Object
88 89 90 |
# File 'lib/rcrewai/configuration.rb', line 88 def supported_providers %i[openai anthropic google azure ollama] end |
#validate! ⇒ Object
82 83 84 85 86 |
# File 'lib/rcrewai/configuration.rb', line 82 def validate! raise ConfigurationError, 'LLM provider must be set' if @llm_provider.nil? raise ConfigurationError, "API key must be set for #{@llm_provider}" if api_key.nil? || api_key.empty? raise ConfigurationError, "Model must be set for #{@llm_provider}" if model.nil? || model.empty? end |
#with_overrides(provider: nil, model: nil, api_key: nil, temperature: nil) ⇒ Object
Returns a copy of this configuration with the given per-agent overrides applied. The original configuration is left untouched, so agents can each target a different provider/model without mutating global state.
config.with_overrides(provider: :anthropic, model: 'claude-3-opus-20240229')
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rcrewai/configuration.rb', line 67 def with_overrides(provider: nil, model: nil, api_key: nil, temperature: nil) copy = dup copy.llm_provider = provider.to_sym if provider target = copy.llm_provider copy.public_send("#{target}_model=", model) if model && copy.respond_to?("#{target}_model=") copy.model = model if model copy.public_send("#{target}_api_key=", api_key) if api_key && copy.respond_to?("#{target}_api_key=") copy.api_key = api_key if api_key copy.temperature = temperature unless temperature.nil? copy end |