Class: Kward::AzureOpenAIConfig
- Inherits:
-
Object
- Object
- Kward::AzureOpenAIConfig
- Defined in:
- lib/kward/model/azure_openai_config.rb
Overview
Validated Azure OpenAI endpoint and deployment settings.
Constant Summary collapse
- DEPLOYMENT_PATTERN =
/\A[a-zA-Z0-9._-]+\z/- API_VERSION_PATTERN =
/\A[a-zA-Z0-9._-]+\z/
Instance Attribute Summary collapse
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#deployment ⇒ Object
readonly
Returns the value of attribute deployment.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
- #chat_completions_url ⇒ Object
-
#initialize(endpoint:, deployment:, api_version:) ⇒ AzureOpenAIConfig
constructor
A new instance of AzureOpenAIConfig.
- #to_config ⇒ Object
Constructor Details
#initialize(endpoint:, deployment:, api_version:) ⇒ AzureOpenAIConfig
Returns a new instance of AzureOpenAIConfig.
10 11 12 13 14 |
# File 'lib/kward/model/azure_openai_config.rb', line 10 def initialize(endpoint:, deployment:, api_version:) @endpoint = normalize_endpoint(endpoint) @deployment = validate_value(deployment, "deployment name", DEPLOYMENT_PATTERN) @api_version = validate_value(api_version, "API version", API_VERSION_PATTERN) end |
Instance Attribute Details
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
16 17 18 |
# File 'lib/kward/model/azure_openai_config.rb', line 16 def api_version @api_version end |
#deployment ⇒ Object (readonly)
Returns the value of attribute deployment.
16 17 18 |
# File 'lib/kward/model/azure_openai_config.rb', line 16 def deployment @deployment end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
16 17 18 |
# File 'lib/kward/model/azure_openai_config.rb', line 16 def endpoint @endpoint end |
Instance Method Details
#chat_completions_url ⇒ Object
18 19 20 |
# File 'lib/kward/model/azure_openai_config.rb', line 18 def chat_completions_url URI("#{endpoint}/openai/deployments/#{deployment}/chat/completions?api-version=#{api_version}") end |
#to_config ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/kward/model/azure_openai_config.rb', line 22 def to_config { "azure_openai_endpoint" => endpoint, "azure_openai_model" => deployment, "azure_openai_api_version" => api_version } end |