Class: Riffer::Providers::AzureOpenAI
- Defined in:
- lib/riffer/providers/azure_open_ai.rb
Overview
Azure OpenAI provider for GPT models hosted on Azure.
Requires the openai gem to be installed.
Credentials are resolved in order:
-
Keyword arguments (
api_key,base_url) -
Config (
Riffer.config.azure_openai.api_key/.endpoint) -
Environment variables (
AZURE_OPENAI_API_KEY/AZURE_OPENAI_ENDPOINT)
Riffer::Providers::AzureOpenAI.new(
api_key: "key",
base_url: "https://my-resource.openai.azure.com"
)
Constant Summary
Constants inherited from OpenAI
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(**options) ⇒ AzureOpenAI
constructor
Initializes the Azure OpenAI provider.
Methods inherited from Base
#generate_text, skills_adapter, #stream_text
Methods included from Messages::Converter
#convert_to_file_part, #convert_to_message_object
Methods included from Helpers::Dependencies
Constructor Details
#initialize(**options) ⇒ AzureOpenAI
Initializes the Azure OpenAI provider.
- api_key
-
Azure OpenAI API key. Falls back to config, then
AZURE_OPENAI_API_KEY. - base_url
-
Azure OpenAI endpoint URL. Falls back to config, then
AZURE_OPENAI_ENDPOINT.
– : (**untyped) -> void
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/riffer/providers/azure_open_ai.rb', line 26 def initialize(**) depends_on "openai" api_key = .fetch(:api_key) { Riffer.config.azure_openai.api_key || ENV["AZURE_OPENAI_API_KEY"] } base_url = .fetch(:base_url) { Riffer.config.azure_openai.endpoint || ENV["AZURE_OPENAI_ENDPOINT"] } @client = ::OpenAI::Client.new( api_key: api_key, base_url: base_url, **.except(:api_key, :base_url) ) end |