Class: ActiveAgent::Providers::AzureProvider::AzureClient

Inherits:
OpenAI::Client
  • Object
show all
Defined in:
lib/active_agent/providers/azure_provider.rb

Overview

Custom OpenAI client for Azure OpenAI Service.

Azure uses different authentication headers (api-key instead of Authorization: Bearer) and requires api-version as a query parameter on all requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, base_url:, api_version:, max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ AzureClient

Creates a new Azure OpenAI client.

Parameters:

  • api_key (String)

    Azure OpenAI API key

  • base_url (String)

    Azure endpoint URL

  • api_version (String)

    API version (e.g., “2024-10-21”)

  • max_retries (Integer) (defaults to: self.class::DEFAULT_MAX_RETRIES)

    Maximum retry attempts

  • timeout (Float) (defaults to: self.class::DEFAULT_TIMEOUT_IN_SECONDS)

    Request timeout in seconds

  • initial_retry_delay (Float) (defaults to: self.class::DEFAULT_INITIAL_RETRY_DELAY)

    Initial delay between retries

  • max_retry_delay (Float) (defaults to: self.class::DEFAULT_MAX_RETRY_DELAY)

    Maximum delay between retries



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/active_agent/providers/azure_provider.rb', line 80

def initialize(
  api_key:,
  base_url:,
  api_version:,
  max_retries: self.class::DEFAULT_MAX_RETRIES,
  timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
  initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
  max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
)
  @api_version = api_version

  super(
    api_key: api_key,
    base_url: base_url,
    max_retries: max_retries,
    timeout: timeout,
    initial_retry_delay: initial_retry_delay,
    max_retry_delay: max_retry_delay
  )
end

Instance Attribute Details

#api_versionString (readonly)

Returns:

  • (String)


69
70
71
# File 'lib/active_agent/providers/azure_provider.rb', line 69

def api_version
  @api_version
end