Class: OpenAI::RequestOptions
- Inherits:
-
Internal::Type::BaseModel
- Object
- Internal::Type::BaseModel
- OpenAI::RequestOptions
- Defined in:
- lib/openai/request_options.rb
Overview
Specify HTTP behaviour to use for a specific request. These options supplement or override those provided at the client level.
When making a request, you can pass an actual RequestOptions instance, or simply pass a Hash with symbol keys matching the attributes on this class.
Instance Attribute Summary collapse
-
#extra_body ⇒ Object?
Extra data to send with the request.
-
#extra_headers ⇒ Hash{String=>String, nil}?
Extra headers to send with the request.
-
#extra_query ⇒ Hash{String=>Array<String>, String, nil}?
Extra query params to send with the request.
-
#idempotency_key ⇒ String?
Idempotency key to send with request and all associated retries.
-
#max_retries ⇒ Integer?
Maximum number of retries to attempt after a failed initial request.
-
#timeout ⇒ Float?
Request timeout in seconds.
Class Method Summary collapse
- .validate!(opts) ⇒ Object private
Instance Method Summary collapse
-
#initialize(values = {}) ⇒ Object
constructor
Returns a new instance of RequestOptions.
Methods inherited from Internal::Type::BaseModel
==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml
Methods included from Internal::Type::Converter
#coerce, coerce, #dump, dump, #inspect, inspect, type_info
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(values = {}) ⇒ Object
Returns a new instance of RequestOptions.
73 74 75 |
# File 'lib/openai/request_options.rb', line 73 define_sorbet_constant!(:OrHash) do T.type_alias { T.any(OpenAI::RequestOptions, OpenAI::Internal::AnyHash) } end |
Instance Attribute Details
#extra_body ⇒ Object?
Extra data to send with the request. These are deep merged into any data generated as part of the normal request.
54 |
# File 'lib/openai/request_options.rb', line 54 optional :extra_body, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown] |
#extra_headers ⇒ Hash{String=>String, nil}?
Extra headers to send with the request. These are ‘.merged`’d into any `extra_headers` given at the client level.
47 |
# File 'lib/openai/request_options.rb', line 47 optional :extra_headers, OpenAI::Internal::Type::HashOf[String, nil?: true] |
#extra_query ⇒ Hash{String=>Array<String>, String, nil}?
Extra query params to send with the request. These are ‘.merge`’d into any `query` given at the client level.
40 |
# File 'lib/openai/request_options.rb', line 40 optional :extra_query, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::ArrayOf[String]] |
#idempotency_key ⇒ String?
Idempotency key to send with request and all associated retries. Will only be sent for write requests.
33 |
# File 'lib/openai/request_options.rb', line 33 optional :idempotency_key, String |
#max_retries ⇒ Integer?
Maximum number of retries to attempt after a failed initial request.
60 |
# File 'lib/openai/request_options.rb', line 60 optional :max_retries, Integer |
#timeout ⇒ Float?
Request timeout in seconds.
66 |
# File 'lib/openai/request_options.rb', line 66 optional :timeout, Float |
Class Method Details
.validate!(opts) ⇒ 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.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/openai/request_options.rb', line 15 def self.validate!(opts) case opts in OpenAI::RequestOptions | Hash opts.to_h.each_key do |k| unless fields.include?(k) raise ArgumentError.new("Request `opts` keys must be one of #{fields.keys}, got #{k.inspect}") end end else raise ArgumentError.new("Request `opts` must be a Hash or RequestOptions, got #{opts.inspect}") end end |