Class: ActiveHarness::Configuration
- Inherits:
-
Object
- Object
- ActiveHarness::Configuration
- Defined in:
- lib/active_harness/configuration.rb
Overview
Central configuration object.
Usage in config/initializers/active_harness.rb:
ActiveHarness.configure do |config|
config.openai_api_key = ENV["OPENAI_API_KEY"]
config.openai_api_url = "https://api.openai.com/v1/chat/completions"
# ...
end
If a value is not explicitly set, it is read from the corresponding environment variable so all existing ENV-based setups keep working.
Instance Attribute Summary collapse
-
#anthropic_api_key ⇒ Object
————————————————————————- Anthropic ————————————————————————-.
-
#anthropic_api_url ⇒ Object
Returns the value of attribute anthropic_api_url.
-
#azure_ai_auth_token ⇒ Object
Bearer token (alternative to api-key).
-
#azure_api_base ⇒ Object
e.g.
-
#azure_api_key ⇒ Object
————————————————————————- Azure OpenAI Service ————————————————————————-.
-
#azure_api_version ⇒ Object
e.g.
-
#deepseek_api_key ⇒ Object
————————————————————————- DeepSeek ————————————————————————-.
-
#deepseek_api_url ⇒ Object
Returns the value of attribute deepseek_api_url.
-
#gemini_api_key ⇒ Object
————————————————————————- Google Gemini (OpenAI-compatible REST endpoint) ————————————————————————-.
-
#gemini_api_url ⇒ Object
Returns the value of attribute gemini_api_url.
-
#gpustack_api_base ⇒ Object
Returns the value of attribute gpustack_api_base.
-
#gpustack_api_key ⇒ Object
————————————————————————- GPUStack (self-hosted — key is optional) ————————————————————————-.
-
#groq_api_key ⇒ Object
————————————————————————- Groq ————————————————————————-.
-
#groq_api_url ⇒ Object
Returns the value of attribute groq_api_url.
-
#mistral_api_key ⇒ Object
————————————————————————- Mistral ————————————————————————-.
-
#mistral_api_url ⇒ Object
Returns the value of attribute mistral_api_url.
-
#ollama_api_base ⇒ Object
Returns the value of attribute ollama_api_base.
-
#ollama_api_key ⇒ Object
————————————————————————- Ollama (local — key is optional) ————————————————————————-.
-
#openai_api_key ⇒ Object
————————————————————————- OpenAI ————————————————————————-.
-
#openai_api_url ⇒ Object
Returns the value of attribute openai_api_url.
-
#openrouter_api_key ⇒ Object
————————————————————————- OpenRouter ————————————————————————-.
-
#openrouter_api_url ⇒ Object
Returns the value of attribute openrouter_api_url.
-
#openrouter_http_referer ⇒ Object
Returns the value of attribute openrouter_http_referer.
-
#perplexity_api_key ⇒ Object
————————————————————————- Perplexity ————————————————————————-.
-
#perplexity_api_url ⇒ Object
Returns the value of attribute perplexity_api_url.
-
#request_timeout ⇒ Object
————————————————————————- Global ————————————————————————-.
-
#retry_default_attempts ⇒ Object
Retry policy for a single model (exponential backoff).
-
#retry_default_delay ⇒ Object
Returns the value of attribute retry_default_delay.
-
#xai_api_key ⇒ Object
————————————————————————- xAI (Grok) ————————————————————————-.
-
#xai_api_url ⇒ Object
Returns the value of attribute xai_api_url.
Instance Method Summary collapse
-
#custom ⇒ Object
————————————————————————- Custom providers.
-
#initialize ⇒ Configuration
constructor
————————————————————————- Defaults — all keys fall back to the corresponding ENV variable so that existing ENV-based setups keep working without any changes.
Constructor Details
#initialize ⇒ Configuration
Defaults — all keys fall back to the corresponding ENV variable so that existing ENV-based setups keep working without any changes.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/active_harness/configuration.rb', line 128 def initialize @request_timeout = 10 @retry_default_attempts = 3 @retry_default_delay = 1.0 @openai_api_key = ENV["OPENAI_API_KEY"] @openai_api_url = "https://api.openai.com/v1/chat/completions" @anthropic_api_key = ENV["ANTHROPIC_API_KEY"] @anthropic_api_url = "https://api.anthropic.com/v1/messages" @gemini_api_key = ENV["GEMINI_API_KEY"] @gemini_api_url = "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions" @groq_api_key = ENV["GROQ_API_KEY"] @groq_api_url = "https://api.groq.com/openai/v1/chat/completions" @openrouter_api_key = ENV["OPENROUTER_API_KEY"] @openrouter_api_url = "https://openrouter.ai/api/v1/chat/completions" @openrouter_http_referer = "https://github.com/the-teacher/ActiveHarness" @xai_api_key = ENV["XAI_API_KEY"] @xai_api_url = "https://api.x.ai/v1/chat/completions" @deepseek_api_key = ENV["DEEPSEEK_API_KEY"] @deepseek_api_url = "https://api.deepseek.com/v1/chat/completions" @mistral_api_key = ENV["MISTRAL_API_KEY"] @mistral_api_url = "https://api.mistral.ai/v1/chat/completions" @ollama_api_key = ENV["OLLAMA_API_KEY"] # nil if not set — key is optional @ollama_api_base = ENV.fetch("OLLAMA_API_BASE", "http://localhost:11434") @perplexity_api_key = ENV["PERPLEXITY_API_KEY"] @perplexity_api_url = "https://api.perplexity.ai/chat/completions" @gpustack_api_key = ENV["GPUSTACK_API_KEY"] # nil if not set — key is optional @gpustack_api_base = ENV["GPUSTACK_API_BASE"] @azure_api_key = ENV["AZURE_API_KEY"] @azure_ai_auth_token = ENV["AZURE_AI_AUTH_TOKEN"] @azure_api_base = ENV["AZURE_API_BASE"] @azure_api_version = ENV.fetch("AZURE_API_VERSION", "2024-05-01-preview") end |
Instance Attribute Details
#anthropic_api_key ⇒ Object
Anthropic
35 36 37 |
# File 'lib/active_harness/configuration.rb', line 35 def anthropic_api_key @anthropic_api_key end |
#anthropic_api_url ⇒ Object
Returns the value of attribute anthropic_api_url.
36 37 38 |
# File 'lib/active_harness/configuration.rb', line 36 def anthropic_api_url @anthropic_api_url end |
#azure_ai_auth_token ⇒ Object
Bearer token (alternative to api-key)
97 98 99 |
# File 'lib/active_harness/configuration.rb', line 97 def azure_ai_auth_token @azure_ai_auth_token end |
#azure_api_base ⇒ Object
e.g. “my-resource.openai.azure.com”
98 99 100 |
# File 'lib/active_harness/configuration.rb', line 98 def azure_api_base @azure_api_base end |
#azure_api_key ⇒ Object
Azure OpenAI Service
96 97 98 |
# File 'lib/active_harness/configuration.rb', line 96 def azure_api_key @azure_api_key end |
#azure_api_version ⇒ Object
e.g. “2024-05-01-preview”
99 100 101 |
# File 'lib/active_harness/configuration.rb', line 99 def azure_api_version @azure_api_version end |
#deepseek_api_key ⇒ Object
DeepSeek
66 67 68 |
# File 'lib/active_harness/configuration.rb', line 66 def deepseek_api_key @deepseek_api_key end |
#deepseek_api_url ⇒ Object
Returns the value of attribute deepseek_api_url.
67 68 69 |
# File 'lib/active_harness/configuration.rb', line 67 def deepseek_api_url @deepseek_api_url end |
#gemini_api_key ⇒ Object
Google Gemini (OpenAI-compatible REST endpoint)
41 42 43 |
# File 'lib/active_harness/configuration.rb', line 41 def gemini_api_key @gemini_api_key end |
#gemini_api_url ⇒ Object
Returns the value of attribute gemini_api_url.
42 43 44 |
# File 'lib/active_harness/configuration.rb', line 42 def gemini_api_url @gemini_api_url end |
#gpustack_api_base ⇒ Object
Returns the value of attribute gpustack_api_base.
91 92 93 |
# File 'lib/active_harness/configuration.rb', line 91 def gpustack_api_base @gpustack_api_base end |
#gpustack_api_key ⇒ Object
GPUStack (self-hosted — key is optional)
90 91 92 |
# File 'lib/active_harness/configuration.rb', line 90 def gpustack_api_key @gpustack_api_key end |
#groq_api_key ⇒ Object
Groq
47 48 49 |
# File 'lib/active_harness/configuration.rb', line 47 def groq_api_key @groq_api_key end |
#groq_api_url ⇒ Object
Returns the value of attribute groq_api_url.
48 49 50 |
# File 'lib/active_harness/configuration.rb', line 48 def groq_api_url @groq_api_url end |
#mistral_api_key ⇒ Object
Mistral
72 73 74 |
# File 'lib/active_harness/configuration.rb', line 72 def mistral_api_key @mistral_api_key end |
#mistral_api_url ⇒ Object
Returns the value of attribute mistral_api_url.
73 74 75 |
# File 'lib/active_harness/configuration.rb', line 73 def mistral_api_url @mistral_api_url end |
#ollama_api_base ⇒ Object
Returns the value of attribute ollama_api_base.
79 80 81 |
# File 'lib/active_harness/configuration.rb', line 79 def ollama_api_base @ollama_api_base end |
#ollama_api_key ⇒ Object
Ollama (local — key is optional)
78 79 80 |
# File 'lib/active_harness/configuration.rb', line 78 def ollama_api_key @ollama_api_key end |
#openai_api_key ⇒ Object
OpenAI
29 30 31 |
# File 'lib/active_harness/configuration.rb', line 29 def openai_api_key @openai_api_key end |
#openai_api_url ⇒ Object
Returns the value of attribute openai_api_url.
30 31 32 |
# File 'lib/active_harness/configuration.rb', line 30 def openai_api_url @openai_api_url end |
#openrouter_api_key ⇒ Object
OpenRouter
53 54 55 |
# File 'lib/active_harness/configuration.rb', line 53 def openrouter_api_key @openrouter_api_key end |
#openrouter_api_url ⇒ Object
Returns the value of attribute openrouter_api_url.
54 55 56 |
# File 'lib/active_harness/configuration.rb', line 54 def openrouter_api_url @openrouter_api_url end |
#openrouter_http_referer ⇒ Object
Returns the value of attribute openrouter_http_referer.
55 56 57 |
# File 'lib/active_harness/configuration.rb', line 55 def openrouter_http_referer @openrouter_http_referer end |
#perplexity_api_key ⇒ Object
Perplexity
84 85 86 |
# File 'lib/active_harness/configuration.rb', line 84 def perplexity_api_key @perplexity_api_key end |
#perplexity_api_url ⇒ Object
Returns the value of attribute perplexity_api_url.
85 86 87 |
# File 'lib/active_harness/configuration.rb', line 85 def perplexity_api_url @perplexity_api_url end |
#request_timeout ⇒ Object
Global
18 19 20 |
# File 'lib/active_harness/configuration.rb', line 18 def request_timeout @request_timeout end |
#retry_default_attempts ⇒ Object
Retry policy for a single model (exponential backoff). Set retry_default_attempts to 1 to disable retries entirely. Per-model values can be set via retry_attempts: / retry_delay: in the DSL.
23 24 25 |
# File 'lib/active_harness/configuration.rb', line 23 def retry_default_attempts @retry_default_attempts end |
#retry_default_delay ⇒ Object
Returns the value of attribute retry_default_delay.
24 25 26 |
# File 'lib/active_harness/configuration.rb', line 24 def retry_default_delay @retry_default_delay end |
#xai_api_key ⇒ Object
xAI (Grok)
60 61 62 |
# File 'lib/active_harness/configuration.rb', line 60 def xai_api_key @xai_api_key end |
#xai_api_url ⇒ Object
Returns the value of attribute xai_api_url.
61 62 63 |
# File 'lib/active_harness/configuration.rb', line 61 def xai_api_url @xai_api_url end |
Instance Method Details
#custom ⇒ Object
Custom providers
Register any OpenAI-compatible endpoint under an arbitrary name:
ActiveHarness.configure do |config|
config.custom["MyLocal"]["url"] = "http://localhost:8080/v1/chat/completions"
config.custom["MyLocal"]["api_key"] = ENV["MYLOCAL_API_KEY"] # omit if no auth
config.custom["SecondProvider"]["url"] = "https://second.example.com/v1/chat/completions"
config.custom["SecondProvider"]["api_key"] = ENV["SECOND_API_KEY"]
end
Use in an agent:
model do
use provider: :custom, name: "MyLocal", model: "llama3.2"
fallback provider: :custom, name: "SecondProvider", model: "mixtral"
end
120 121 122 |
# File 'lib/active_harness/configuration.rb', line 120 def custom @custom ||= Hash.new { |h, k| h[k] = {} } end |