Class: Riffer::Providers::AzureOpenAI

Inherits:
OpenAI
  • Object
show all
Defined in:
lib/riffer/providers/azure_open_ai.rb

Overview

Azure OpenAI provider for GPT models hosted on Azure. Requires the openai gem. Credentials resolve from kwargs, then config, then AZURE_OPENAI_API_KEY / AZURE_OPENAI_ENDPOINT.

Constant Summary

Constants inherited from OpenAI

OpenAI::WEB_SEARCH_TOOL_TYPE

Constants inherited from Base

Base::WIRE_SEPARATOR

Instance Method Summary collapse

Methods inherited from Base

#generate_text, skills_adapter, #stream_text

Constructor Details

#initialize(**options) ⇒ AzureOpenAI

– : (**untyped) -> void



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/riffer/providers/azure_open_ai.rb', line 10

def initialize(**options)
  depends_on "openai"

  api_key = options.fetch(:api_key) {
    Riffer.config.azure_openai.api_key || ENV["AZURE_OPENAI_API_KEY"]
  }
  base_url = options.fetch(:base_url) {
    Riffer.config.azure_openai.endpoint || ENV["AZURE_OPENAI_ENDPOINT"]
  }
  @client = ::OpenAI::Client.new(
    api_key: api_key,
    base_url: base_url,
    **options.except(:api_key, :base_url)
  )
end