Class: OpenAI::Internal::RequestOptionsScope Private
- Inherits:
-
Object
- Object
- OpenAI::Internal::RequestOptionsScope
- Defined in:
- lib/openai/internal/request_options_scope.rb,
sig/openai/internal/request_options_scope.rbs
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Derives request options for the individual writes in a composite helper.
A caller-supplied idempotency key names the composite operation. Each child write receives a deterministic derived key so its retries remain stable without colliding with another write in the same operation. Structured keys are materialized as the standard header; an explicit header remains authoritative.
Instance Method Summary collapse
- #child(operation) ⇒ Hash{Symbol=>Object} private
-
#initialize(request_options) ⇒ RequestOptionsScope
constructor
private
A new instance of RequestOptionsScope.
Constructor Details
#initialize(request_options) ⇒ RequestOptionsScope
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RequestOptionsScope.
22 23 24 25 26 27 28 29 30 |
# File 'lib/openai/internal/request_options_scope.rb', line 22 def initialize() = .to_h.dup OpenAI::RequestOptions.validate!() if .key?(:extra_headers) [:extra_headers] = [:extra_headers].to_h.dup.freeze end @options = .freeze end |
Instance Method Details
#child(operation) ⇒ Hash{Symbol=>Object}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/openai/internal/request_options_scope.rb', line 36 def child(operation) = @options.dup key = [:idempotency_key] derived_key = derive(key, operation) unless key.nil? [:idempotency_key] = derived_key unless derived_key.nil? headers = [:extra_headers].to_h header = headers.keys.reverse.find { _1.to_s.casecmp?(IDEMPOTENCY_HEADER) } header_key = headers[header] unless header.nil? if header.nil? [:extra_headers] = headers.merge(IDEMPOTENCY_HEADER => derived_key) unless derived_key.nil? elsif !header_key.nil? [:extra_headers] = headers.merge(header => derive(header_key, operation)) end end |