Class: ActiveHarness::Providers::Azure
- Defined in:
- lib/active_harness/providers/azure.rb
Overview
Azure OpenAI Service — deployment-based API. learn.microsoft.com/en-us/azure/ai-services/openai/reference
The ‘model:` parameter is treated as the **deployment name** you created in the Azure portal (not the underlying model name).
Required config (or ENV fallback):
config.azure_api_base — "https://my-resource.openai.azure.com"
config.azure_api_key — your resource API key
(alternatively: config.azure_ai_auth_token for OAuth bearer)
Optional config:
config.azure_api_version — defaults to "2024-05-01-preview"
Resulting endpoint:
POST {azure_api_base}/openai/deployments/{deployment}/chat/completions
?api-version={azure_api_version}
Example agent config:
model do
use provider: :azure, model: "my-gpt4o-deployment", temperature: 0.7
end
Constant Summary
Constants inherited from Base
Base::HTTP, Base::STREAMING_HTTP
Instance Method Summary collapse
Instance Method Details
#call(model:, messages:, temperature: 0.7) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/active_harness/providers/azure.rb', line 28 def call(model:, messages:, temperature: 0.7) url = build_url(model) raw = post_json(url, headers: { "Content-Type" => "application/json" }.merge(auth_header), body: { messages: , temperature: temperature } ) data = parse!(raw) handle_error!(data) { content: data.dig("choices", 0, "message", "content").to_s.strip, provider: :azure, model: data["model"] || model, usage: extract_usage_openai(data) } end |