Class: ActiveAgent::Providers::AzureProvider

Inherits:
OpenAI::ChatProvider show all
Defined in:
lib/active_agent/providers/azure_provider.rb

Overview

Provider for Azure OpenAI Service via OpenAI-compatible API.

Azure OpenAI uses the same API structure as OpenAI but with different authentication (api-key header) and endpoint configuration (resource + deployment).

Examples:

Configuration in active_agent.yml

azure_openai:
  service: "AzureOpenAI"
  api_key: <%= ENV["AZURE_OPENAI_API_KEY"] %>
  azure_resource: "mycompany"
  deployment_id: "gpt-4-deployment"
  api_version: "2024-10-21"

See Also:

Defined Under Namespace

Classes: AzureClient

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ToolChoiceClearing

#prepare_prompt_request_tools

Methods inherited from BaseProvider

#embed, #initialize, namespace, #preview, #prompt, tag_name

Methods included from Previewable

#preview_prompt

Methods included from Instrumentation

#instrumentation_prompt_payload

Methods included from ExceptionHandler

#configure_exception_handler, #rescue_with_handler, #with_exception_handling

Constructor Details

This class inherits a constructor from ActiveAgent::Providers::BaseProvider

Class Method Details

.embed_request_typeActiveModel::Type::Value

Returns:

  • (ActiveModel::Type::Value)


41
42
43
# File 'lib/active_agent/providers/azure_provider.rb', line 41

def self.embed_request_type
  OpenAI::Embedding::RequestType.new
end

.options_klassClass

Returns:

  • (Class)


31
32
33
# File 'lib/active_agent/providers/azure_provider.rb', line 31

def self.options_klass
  Azure::Options
end

.prompt_request_typeActiveModel::Type::Value

Returns:

  • (ActiveModel::Type::Value)


36
37
38
# File 'lib/active_agent/providers/azure_provider.rb', line 36

def self.prompt_request_type
  OpenAI::Chat::RequestType.new
end

.service_nameString

Returns:

  • (String)


26
27
28
# File 'lib/active_agent/providers/azure_provider.rb', line 26

def self.service_name
  "AzureOpenAI"
end

Instance Method Details

#clientAzureClient

Returns a configured Azure OpenAI client.

Uses a custom client subclass that handles Azure-specific authentication (api-key header instead of Authorization: Bearer).

Returns:



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/active_agent/providers/azure_provider.rb', line 51

def client
  @client ||= AzureClient.new(
    api_key: options.api_key,
    base_url: options.base_url,
    api_version: options.api_version,
    max_retries: options.max_retries,
    timeout: options.timeout,
    initial_retry_delay: options.initial_retry_delay,
    max_retry_delay: options.max_retry_delay
  )
end