venice_client 1.0.20 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -1
- data/docs/AudioModelPricingInput.md +0 -2
- data/docs/CacheControl.md +20 -0
- data/docs/ChatApi.md +1 -1
- data/docs/ChatCompletionRequest.md +7 -1
- data/docs/ChatCompletionRequestReasoning.md +18 -0
- data/docs/ChatCompletionRequestVeniceParameters.md +3 -1
- data/docs/CompleteVideo200Response.md +18 -0
- data/docs/CompleteVideoRequest.md +20 -0
- data/docs/CreateChatCompletion200Response.md +1 -1
- data/docs/CreateChatCompletion200ResponseVeniceParameters.md +2 -0
- data/docs/GenerateImageRequest.md +9 -3
- data/docs/GetApiKeyRateLimitLogs200ResponseDataInner.md +1 -1
- data/docs/GetApiKeyRateLimits200Response.md +0 -2
- data/docs/GetApiKeyRateLimits200ResponseDataBalances.md +0 -2
- data/docs/GetApiKeyRateLimits200ResponseDataRateLimitsInner.md +1 -1
- data/docs/ImageApi.md +1 -1
- data/docs/ImageModelPricingGeneration.md +0 -2
- data/docs/ImageModelPricingUpscale2x.md +0 -2
- data/docs/ImageModelPricingUpscale4x.md +0 -2
- data/docs/ImageUrl.md +2 -0
- data/docs/LLMModelPricingInput.md +0 -2
- data/docs/LLMModelPricingOutput.md +0 -2
- data/docs/ModelResponseModelSpec.md +2 -0
- data/docs/ModelResponseModelSpecConstraints.md +13 -1
- data/docs/ModelsApi.md +2 -2
- data/docs/QueueVideo200Response.md +20 -0
- data/docs/QueueVideoRequest.md +32 -0
- data/docs/QuoteVideo200Response.md +18 -0
- data/docs/RetrieveVideo200Response.md +22 -0
- data/docs/RetrieveVideoRequest.md +22 -0
- data/docs/SimpleGenerateImageRequest.md +1 -1
- data/docs/Text.md +2 -0
- data/docs/VideoApi.md +295 -0
- data/docs/VideoModelConstraints.md +28 -0
- data/lib/venice_client/api/api_keys_api.rb +1 -1
- data/lib/venice_client/api/audio_api.rb +1 -1
- data/lib/venice_client/api/billing_api.rb +1 -1
- data/lib/venice_client/api/characters_api.rb +1 -1
- data/lib/venice_client/api/chat_api.rb +1 -1
- data/lib/venice_client/api/embeddings_api.rb +1 -1
- data/lib/venice_client/api/image_api.rb +1 -1
- data/lib/venice_client/api/models_api.rb +3 -3
- data/lib/venice_client/api/preview_api.rb +1 -1
- data/lib/venice_client/api/speech_api.rb +1 -1
- data/lib/venice_client/api/video_api.rb +278 -0
- data/lib/venice_client/api_client.rb +1 -1
- data/lib/venice_client/api_error.rb +1 -1
- data/lib/venice_client/configuration.rb +1 -1
- data/lib/venice_client/models/assistant_message.rb +8 -8
- data/lib/venice_client/models/assistant_message_content.rb +1 -1
- data/lib/venice_client/models/audio_model_pricing.rb +1 -1
- data/lib/venice_client/models/audio_model_pricing_input.rb +2 -29
- data/lib/venice_client/models/billing_usage_request.rb +1 -1
- data/lib/venice_client/models/billing_usage_response.rb +1 -1
- data/lib/venice_client/models/cache_control.rb +273 -0
- data/lib/venice_client/models/chat_completion_request.rb +65 -2
- data/lib/venice_client/models/chat_completion_request_messages_inner.rb +2 -2
- data/lib/venice_client/models/chat_completion_request_reasoning.rb +256 -0
- data/lib/venice_client/models/chat_completion_request_response_format.rb +1 -1
- data/lib/venice_client/models/chat_completion_request_stop.rb +1 -1
- data/lib/venice_client/models/chat_completion_request_stream_options.rb +1 -1
- data/lib/venice_client/models/chat_completion_request_tool_choice.rb +1 -1
- data/lib/venice_client/models/chat_completion_request_tool_choice_any_of.rb +1 -1
- data/lib/venice_client/models/chat_completion_request_tool_choice_any_of_function.rb +1 -1
- data/lib/venice_client/models/chat_completion_request_venice_parameters.rb +15 -3
- data/lib/venice_client/models/complete_video200_response.rb +238 -0
- data/lib/venice_client/models/complete_video_request.rb +265 -0
- data/lib/venice_client/models/create_api_key200_response.rb +1 -1
- data/lib/venice_client/models/create_api_key200_response_data.rb +1 -1
- data/lib/venice_client/models/create_api_key_request.rb +1 -1
- data/lib/venice_client/models/create_api_key_request_expires_at.rb +1 -1
- data/lib/venice_client/models/create_chat_completion200_response.rb +11 -19
- data/lib/venice_client/models/create_chat_completion200_response_choices_inner.rb +9 -9
- data/lib/venice_client/models/create_chat_completion200_response_choices_inner_logprobs.rb +1 -1
- data/lib/venice_client/models/create_chat_completion200_response_choices_inner_logprobs_top_logprobs_inner.rb +1 -1
- data/lib/venice_client/models/create_chat_completion200_response_choices_inner_message.rb +2 -2
- data/lib/venice_client/models/create_chat_completion200_response_usage.rb +1 -1
- data/lib/venice_client/models/create_chat_completion200_response_venice_parameters.rb +29 -2
- data/lib/venice_client/models/create_chat_completion200_response_venice_parameters_web_search_citations_inner.rb +1 -1
- data/lib/venice_client/models/create_embedding200_response.rb +1 -1
- data/lib/venice_client/models/create_embedding200_response_data_inner.rb +1 -1
- data/lib/venice_client/models/create_embedding200_response_usage.rb +1 -1
- data/lib/venice_client/models/create_embedding_request_schema.rb +1 -1
- data/lib/venice_client/models/create_embedding_request_schema_input.rb +1 -1
- data/lib/venice_client/models/create_embedding_request_schema_model.rb +1 -1
- data/lib/venice_client/models/create_speech_request_schema.rb +1 -1
- data/lib/venice_client/models/delete_api_key200_response.rb +1 -1
- data/lib/venice_client/models/detailed_error.rb +1 -1
- data/lib/venice_client/models/edit_image_request.rb +1 -1
- data/lib/venice_client/models/edit_image_request_image.rb +1 -1
- data/lib/venice_client/models/generate_image200_response.rb +1 -1
- data/lib/venice_client/models/generate_image200_response_timing.rb +1 -1
- data/lib/venice_client/models/generate_image_request.rb +44 -42
- data/lib/venice_client/models/get_api_key_by_id200_response.rb +1 -1
- data/lib/venice_client/models/get_api_key_by_id200_response_data.rb +1 -1
- data/lib/venice_client/models/get_api_key_generate_web3_key200_response.rb +1 -1
- data/lib/venice_client/models/get_api_key_generate_web3_key200_response_data.rb +1 -1
- data/lib/venice_client/models/get_api_key_rate_limit_logs200_response.rb +1 -1
- data/lib/venice_client/models/get_api_key_rate_limit_logs200_response_data_inner.rb +2 -2
- data/lib/venice_client/models/get_api_key_rate_limits200_response.rb +2 -12
- data/lib/venice_client/models/get_api_key_rate_limits200_response_data.rb +1 -1
- data/lib/venice_client/models/get_api_key_rate_limits200_response_data_api_tier.rb +1 -1
- data/lib/venice_client/models/get_api_key_rate_limits200_response_data_balances.rb +2 -12
- data/lib/venice_client/models/get_api_key_rate_limits200_response_data_rate_limits_inner.rb +1 -1
- data/lib/venice_client/models/get_api_key_rate_limits200_response_data_rate_limits_inner_rate_limits_inner.rb +1 -1
- data/lib/venice_client/models/get_api_keys200_response.rb +1 -1
- data/lib/venice_client/models/get_api_keys200_response_data_inner.rb +1 -1
- data/lib/venice_client/models/get_api_keys200_response_data_inner_consumption_limits.rb +1 -1
- data/lib/venice_client/models/get_api_keys200_response_data_inner_usage.rb +1 -1
- data/lib/venice_client/models/get_api_keys200_response_data_inner_usage_trailing_seven_days.rb +1 -1
- data/lib/venice_client/models/get_billing_usage200_response.rb +1 -1
- data/lib/venice_client/models/get_billing_usage200_response_data_inner.rb +1 -1
- data/lib/venice_client/models/get_billing_usage200_response_data_inner_inference_details.rb +1 -1
- data/lib/venice_client/models/get_billing_usage200_response_pagination.rb +1 -1
- data/lib/venice_client/models/get_character_by_slug200_response.rb +1 -1
- data/lib/venice_client/models/image_model_constraints.rb +1 -1
- data/lib/venice_client/models/image_model_constraints_steps.rb +1 -1
- data/lib/venice_client/models/image_model_pricing.rb +1 -1
- data/lib/venice_client/models/image_model_pricing_generation.rb +2 -29
- data/lib/venice_client/models/image_model_pricing_upscale.rb +1 -1
- data/lib/venice_client/models/image_model_pricing_upscale2x.rb +2 -29
- data/lib/venice_client/models/image_model_pricing_upscale4x.rb +2 -29
- data/lib/venice_client/models/image_styles_get200_response.rb +1 -1
- data/lib/venice_client/models/image_url.rb +12 -3
- data/lib/venice_client/models/image_url_object.rb +1 -1
- data/lib/venice_client/models/json_object.rb +1 -1
- data/lib/venice_client/models/json_schema.rb +1 -1
- data/lib/venice_client/models/list_characters200_response.rb +1 -1
- data/lib/venice_client/models/list_characters200_response_data_inner.rb +1 -1
- data/lib/venice_client/models/list_characters200_response_data_inner_stats.rb +1 -1
- data/lib/venice_client/models/list_model_compatibility_mapping200_response.rb +1 -1
- data/lib/venice_client/models/list_model_traits200_response.rb +1 -1
- data/lib/venice_client/models/list_models200_response.rb +1 -1
- data/lib/venice_client/models/list_models200_response_type.rb +1 -1
- data/lib/venice_client/models/list_models_type_parameter.rb +1 -1
- data/lib/venice_client/models/llm_model_pricing.rb +1 -1
- data/lib/venice_client/models/llm_model_pricing_input.rb +2 -29
- data/lib/venice_client/models/llm_model_pricing_output.rb +2 -29
- data/lib/venice_client/models/model_response.rb +3 -3
- data/lib/venice_client/models/model_response_model_spec.rb +46 -2
- data/lib/venice_client/models/model_response_model_spec_capabilities.rb +3 -3
- data/lib/venice_client/models/model_response_model_spec_constraints.rb +3 -2
- data/lib/venice_client/models/model_response_model_spec_pricing.rb +1 -1
- data/lib/venice_client/models/objects_inner.rb +1 -1
- data/lib/venice_client/models/post_api_key_generate_web3_key_request.rb +1 -1
- data/lib/venice_client/models/queue_video200_response.rb +265 -0
- data/lib/venice_client/models/queue_video_request.rb +438 -0
- data/lib/venice_client/models/quote_video200_response.rb +237 -0
- data/lib/venice_client/models/retrieve_video200_response.rb +316 -0
- data/lib/venice_client/models/retrieve_video_request.rb +277 -0
- data/lib/venice_client/models/simple_generate_image200_response.rb +1 -1
- data/lib/venice_client/models/simple_generate_image200_response_data_inner.rb +1 -1
- data/lib/venice_client/models/simple_generate_image200_response_data_inner_any_of.rb +1 -1
- data/lib/venice_client/models/simple_generate_image200_response_data_inner_any_of1.rb +1 -1
- data/lib/venice_client/models/simple_generate_image_request.rb +1 -1
- data/lib/venice_client/models/standard_error.rb +1 -1
- data/lib/venice_client/models/system_message.rb +8 -8
- data/lib/venice_client/models/system_message_content.rb +1 -1
- data/lib/venice_client/models/text.rb +12 -3
- data/lib/venice_client/models/text_model_constraints.rb +1 -1
- data/lib/venice_client/models/text_model_constraints_temperature.rb +1 -1
- data/lib/venice_client/models/text_model_constraints_top_p.rb +1 -1
- data/lib/venice_client/models/tool_call.rb +1 -1
- data/lib/venice_client/models/tool_call_function.rb +1 -1
- data/lib/venice_client/models/tool_message.rb +8 -8
- data/lib/venice_client/models/upscale_image_request.rb +1 -1
- data/lib/venice_client/models/upscale_image_request_enhance.rb +1 -1
- data/lib/venice_client/models/user_message.rb +8 -8
- data/lib/venice_client/models/user_message_content.rb +1 -1
- data/lib/venice_client/models/video_model_constraints.rb +404 -0
- data/lib/venice_client/version.rb +2 -2
- data/lib/venice_client.rb +12 -1
- data/spec/api/video_api_spec.rb +83 -0
- data/spec/models/cache_control_spec.rb +46 -0
- data/spec/models/chat_completion_request_reasoning_spec.rb +40 -0
- data/spec/models/complete_video200_response_spec.rb +36 -0
- data/spec/models/complete_video_request_spec.rb +42 -0
- data/spec/models/queue_video200_response_spec.rb +42 -0
- data/spec/models/queue_video_request_spec.rb +86 -0
- data/spec/models/quote_video200_response_spec.rb +36 -0
- data/spec/models/retrieve_video200_response_spec.rb +52 -0
- data/spec/models/retrieve_video_request_spec.rb +48 -0
- data/spec/models/video_model_constraints_spec.rb +70 -0
- data/spec/spec_helper.rb +1 -1
- data/swagger.yaml +587 -76
- data/update.sh +1 -0
- data/venice_client.gemspec +1 -1
- metadata +46 -2
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Venice.ai API
|
|
3
|
+
|
|
4
|
+
#The Venice.ai API.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 20251209.153516
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.14.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module VeniceClient
|
|
17
|
+
# Optional cache control for prompt caching on supported providers.
|
|
18
|
+
class CacheControl
|
|
19
|
+
# Optional TTL for extended cache duration. Beta feature requiring special header.
|
|
20
|
+
attr_accessor :ttl
|
|
21
|
+
|
|
22
|
+
# The type of cache control. Currently only \"ephemeral\" is supported.
|
|
23
|
+
attr_accessor :type
|
|
24
|
+
|
|
25
|
+
class EnumAttributeValidator
|
|
26
|
+
attr_reader :datatype
|
|
27
|
+
attr_reader :allowable_values
|
|
28
|
+
|
|
29
|
+
def initialize(datatype, allowable_values)
|
|
30
|
+
@allowable_values = allowable_values.map do |value|
|
|
31
|
+
case datatype.to_s
|
|
32
|
+
when /Integer/i
|
|
33
|
+
value.to_i
|
|
34
|
+
when /Float/i
|
|
35
|
+
value.to_f
|
|
36
|
+
else
|
|
37
|
+
value
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def valid?(value)
|
|
43
|
+
!value || allowable_values.include?(value)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
48
|
+
def self.attribute_map
|
|
49
|
+
{
|
|
50
|
+
:'ttl' => :'ttl',
|
|
51
|
+
:'type' => :'type'
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Returns attribute mapping this model knows about
|
|
56
|
+
def self.acceptable_attribute_map
|
|
57
|
+
attribute_map
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Returns all the JSON keys this model knows about
|
|
61
|
+
def self.acceptable_attributes
|
|
62
|
+
acceptable_attribute_map.values
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Attribute type mapping.
|
|
66
|
+
def self.openapi_types
|
|
67
|
+
{
|
|
68
|
+
:'ttl' => :'String',
|
|
69
|
+
:'type' => :'String'
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# List of attributes with nullable: true
|
|
74
|
+
def self.openapi_nullable
|
|
75
|
+
Set.new([
|
|
76
|
+
])
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Initializes the object
|
|
80
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
81
|
+
def initialize(attributes = {})
|
|
82
|
+
if (!attributes.is_a?(Hash))
|
|
83
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `VeniceClient::CacheControl` initialize method"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
87
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
88
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
89
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
90
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `VeniceClient::CacheControl`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
91
|
+
end
|
|
92
|
+
h[k.to_sym] = v
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if attributes.key?(:'ttl')
|
|
96
|
+
self.ttl = attributes[:'ttl']
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
if attributes.key?(:'type')
|
|
100
|
+
self.type = attributes[:'type']
|
|
101
|
+
else
|
|
102
|
+
self.type = nil
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
107
|
+
# @return Array for valid properties with the reasons
|
|
108
|
+
def list_invalid_properties
|
|
109
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
110
|
+
invalid_properties = Array.new
|
|
111
|
+
if @type.nil?
|
|
112
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
invalid_properties
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Check to see if the all the properties in the model are valid
|
|
119
|
+
# @return true if the model is valid
|
|
120
|
+
def valid?
|
|
121
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
122
|
+
return false if @type.nil?
|
|
123
|
+
type_validator = EnumAttributeValidator.new('String', ["ephemeral"])
|
|
124
|
+
return false unless type_validator.valid?(@type)
|
|
125
|
+
true
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
129
|
+
# @param [Object] type Object to be assigned
|
|
130
|
+
def type=(type)
|
|
131
|
+
validator = EnumAttributeValidator.new('String', ["ephemeral"])
|
|
132
|
+
unless validator.valid?(type)
|
|
133
|
+
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
|
134
|
+
end
|
|
135
|
+
@type = type
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Checks equality by comparing each attribute.
|
|
139
|
+
# @param [Object] Object to be compared
|
|
140
|
+
def ==(o)
|
|
141
|
+
return true if self.equal?(o)
|
|
142
|
+
self.class == o.class &&
|
|
143
|
+
ttl == o.ttl &&
|
|
144
|
+
type == o.type
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# @see the `==` method
|
|
148
|
+
# @param [Object] Object to be compared
|
|
149
|
+
def eql?(o)
|
|
150
|
+
self == o
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Calculates hash code according to all attributes.
|
|
154
|
+
# @return [Integer] Hash code
|
|
155
|
+
def hash
|
|
156
|
+
[ttl, type].hash
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Builds the object from hash
|
|
160
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
161
|
+
# @return [Object] Returns the model itself
|
|
162
|
+
def self.build_from_hash(attributes)
|
|
163
|
+
return nil unless attributes.is_a?(Hash)
|
|
164
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
165
|
+
transformed_hash = {}
|
|
166
|
+
openapi_types.each_pair do |key, type|
|
|
167
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
168
|
+
transformed_hash["#{key}"] = nil
|
|
169
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
170
|
+
# check to ensure the input is an array given that the attribute
|
|
171
|
+
# is documented as an array but the input is not
|
|
172
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
173
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
174
|
+
end
|
|
175
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
176
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
new(transformed_hash)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Deserializes the data based on type
|
|
183
|
+
# @param string type Data type
|
|
184
|
+
# @param string value Value to be deserialized
|
|
185
|
+
# @return [Object] Deserialized data
|
|
186
|
+
def self._deserialize(type, value)
|
|
187
|
+
case type.to_sym
|
|
188
|
+
when :Time
|
|
189
|
+
Time.parse(value)
|
|
190
|
+
when :Date
|
|
191
|
+
Date.parse(value)
|
|
192
|
+
when :String
|
|
193
|
+
value.to_s
|
|
194
|
+
when :Integer
|
|
195
|
+
value.to_i
|
|
196
|
+
when :Float
|
|
197
|
+
value.to_f
|
|
198
|
+
when :Boolean
|
|
199
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
200
|
+
true
|
|
201
|
+
else
|
|
202
|
+
false
|
|
203
|
+
end
|
|
204
|
+
when :Object
|
|
205
|
+
# generic object (usually a Hash), return directly
|
|
206
|
+
value
|
|
207
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
208
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
209
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
210
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
211
|
+
k_type = Regexp.last_match[:k_type]
|
|
212
|
+
v_type = Regexp.last_match[:v_type]
|
|
213
|
+
{}.tap do |hash|
|
|
214
|
+
value.each do |k, v|
|
|
215
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
else # model
|
|
219
|
+
# models (e.g. Pet) or oneOf
|
|
220
|
+
klass = VeniceClient.const_get(type)
|
|
221
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Returns the string representation of the object
|
|
226
|
+
# @return [String] String presentation of the object
|
|
227
|
+
def to_s
|
|
228
|
+
to_hash.to_s
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
232
|
+
# @return [Hash] Returns the object in the form of hash
|
|
233
|
+
def to_body
|
|
234
|
+
to_hash
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Returns the object in the form of hash
|
|
238
|
+
# @return [Hash] Returns the object in the form of hash
|
|
239
|
+
def to_hash
|
|
240
|
+
hash = {}
|
|
241
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
242
|
+
value = self.send(attr)
|
|
243
|
+
if value.nil?
|
|
244
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
245
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
hash[param] = _to_hash(value)
|
|
249
|
+
end
|
|
250
|
+
hash
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Outputs non-array value in the form of hash
|
|
254
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
255
|
+
# @param [Object] value Any valid value
|
|
256
|
+
# @return [Hash] Returns the value in the form of hash
|
|
257
|
+
def _to_hash(value)
|
|
258
|
+
if value.is_a?(Array)
|
|
259
|
+
value.compact.map { |v| _to_hash(v) }
|
|
260
|
+
elsif value.is_a?(Hash)
|
|
261
|
+
{}.tap do |hash|
|
|
262
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
263
|
+
end
|
|
264
|
+
elsif value.respond_to? :to_hash
|
|
265
|
+
value.to_hash
|
|
266
|
+
else
|
|
267
|
+
value
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Venice.ai API.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document:
|
|
6
|
+
The version of the OpenAPI document: 20251209.153516
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.14.0
|
|
@@ -51,9 +51,17 @@ module VeniceClient
|
|
|
51
51
|
# Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
|
|
52
52
|
attr_accessor :presence_penalty
|
|
53
53
|
|
|
54
|
+
# When supplied, this field may be used to optimize conversation routing to improve cache performance and thus reduce latency.
|
|
55
|
+
attr_accessor :prompt_cache_key
|
|
56
|
+
|
|
54
57
|
# The parameter for repetition penalty. 1.0 means no penalty. Values > 1.0 discourage repetition.
|
|
55
58
|
attr_accessor :repetition_penalty
|
|
56
59
|
|
|
60
|
+
attr_accessor :reasoning
|
|
61
|
+
|
|
62
|
+
# OpenAI-compatible parameter to control reasoning effort level for supported models. Takes precedence over reasoning.effort if both are provided.
|
|
63
|
+
attr_accessor :reasoning_effort
|
|
64
|
+
|
|
57
65
|
# The random seed used to generate the response. This is useful for reproducibility.
|
|
58
66
|
attr_accessor :seed
|
|
59
67
|
|
|
@@ -91,6 +99,28 @@ module VeniceClient
|
|
|
91
99
|
# A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.
|
|
92
100
|
attr_accessor :tools
|
|
93
101
|
|
|
102
|
+
class EnumAttributeValidator
|
|
103
|
+
attr_reader :datatype
|
|
104
|
+
attr_reader :allowable_values
|
|
105
|
+
|
|
106
|
+
def initialize(datatype, allowable_values)
|
|
107
|
+
@allowable_values = allowable_values.map do |value|
|
|
108
|
+
case datatype.to_s
|
|
109
|
+
when /Integer/i
|
|
110
|
+
value.to_i
|
|
111
|
+
when /Float/i
|
|
112
|
+
value.to_f
|
|
113
|
+
else
|
|
114
|
+
value
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def valid?(value)
|
|
120
|
+
!value || allowable_values.include?(value)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
94
124
|
# Attribute mapping from ruby-style variable name to JSON key.
|
|
95
125
|
def self.attribute_map
|
|
96
126
|
{
|
|
@@ -106,7 +136,10 @@ module VeniceClient
|
|
|
106
136
|
:'model' => :'model',
|
|
107
137
|
:'n' => :'n',
|
|
108
138
|
:'presence_penalty' => :'presence_penalty',
|
|
139
|
+
:'prompt_cache_key' => :'prompt_cache_key',
|
|
109
140
|
:'repetition_penalty' => :'repetition_penalty',
|
|
141
|
+
:'reasoning' => :'reasoning',
|
|
142
|
+
:'reasoning_effort' => :'reasoning_effort',
|
|
110
143
|
:'seed' => :'seed',
|
|
111
144
|
:'stop' => :'stop',
|
|
112
145
|
:'stop_token_ids' => :'stop_token_ids',
|
|
@@ -149,7 +182,10 @@ module VeniceClient
|
|
|
149
182
|
:'model' => :'String',
|
|
150
183
|
:'n' => :'Integer',
|
|
151
184
|
:'presence_penalty' => :'Float',
|
|
185
|
+
:'prompt_cache_key' => :'String',
|
|
152
186
|
:'repetition_penalty' => :'Float',
|
|
187
|
+
:'reasoning' => :'ChatCompletionRequestReasoning',
|
|
188
|
+
:'reasoning_effort' => :'String',
|
|
153
189
|
:'seed' => :'Integer',
|
|
154
190
|
:'stop' => :'ChatCompletionRequestStop',
|
|
155
191
|
:'stop_token_ids' => :'Array<Float>',
|
|
@@ -251,10 +287,22 @@ module VeniceClient
|
|
|
251
287
|
self.presence_penalty = 0
|
|
252
288
|
end
|
|
253
289
|
|
|
290
|
+
if attributes.key?(:'prompt_cache_key')
|
|
291
|
+
self.prompt_cache_key = attributes[:'prompt_cache_key']
|
|
292
|
+
end
|
|
293
|
+
|
|
254
294
|
if attributes.key?(:'repetition_penalty')
|
|
255
295
|
self.repetition_penalty = attributes[:'repetition_penalty']
|
|
256
296
|
end
|
|
257
297
|
|
|
298
|
+
if attributes.key?(:'reasoning')
|
|
299
|
+
self.reasoning = attributes[:'reasoning']
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
if attributes.key?(:'reasoning_effort')
|
|
303
|
+
self.reasoning_effort = attributes[:'reasoning_effort']
|
|
304
|
+
end
|
|
305
|
+
|
|
258
306
|
if attributes.key?(:'seed')
|
|
259
307
|
self.seed = attributes[:'seed']
|
|
260
308
|
end
|
|
@@ -433,6 +481,8 @@ module VeniceClient
|
|
|
433
481
|
return false if !@presence_penalty.nil? && @presence_penalty > 2
|
|
434
482
|
return false if !@presence_penalty.nil? && @presence_penalty < -2
|
|
435
483
|
return false if !@repetition_penalty.nil? && @repetition_penalty < 0
|
|
484
|
+
reasoning_effort_validator = EnumAttributeValidator.new('String', ["low", "medium", "high"])
|
|
485
|
+
return false unless reasoning_effort_validator.valid?(@reasoning_effort)
|
|
436
486
|
return false if !@seed.nil? && @seed <= 0
|
|
437
487
|
return false if !@temperature.nil? && @temperature > 2
|
|
438
488
|
return false if !@temperature.nil? && @temperature < 0
|
|
@@ -584,6 +634,16 @@ module VeniceClient
|
|
|
584
634
|
@repetition_penalty = repetition_penalty
|
|
585
635
|
end
|
|
586
636
|
|
|
637
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
638
|
+
# @param [Object] reasoning_effort Object to be assigned
|
|
639
|
+
def reasoning_effort=(reasoning_effort)
|
|
640
|
+
validator = EnumAttributeValidator.new('String', ["low", "medium", "high"])
|
|
641
|
+
unless validator.valid?(reasoning_effort)
|
|
642
|
+
fail ArgumentError, "invalid value for \"reasoning_effort\", must be one of #{validator.allowable_values}."
|
|
643
|
+
end
|
|
644
|
+
@reasoning_effort = reasoning_effort
|
|
645
|
+
end
|
|
646
|
+
|
|
587
647
|
# Custom attribute writer method with validation
|
|
588
648
|
# @param [Object] seed Value to be assigned
|
|
589
649
|
def seed=(seed)
|
|
@@ -665,7 +725,10 @@ module VeniceClient
|
|
|
665
725
|
model == o.model &&
|
|
666
726
|
n == o.n &&
|
|
667
727
|
presence_penalty == o.presence_penalty &&
|
|
728
|
+
prompt_cache_key == o.prompt_cache_key &&
|
|
668
729
|
repetition_penalty == o.repetition_penalty &&
|
|
730
|
+
reasoning == o.reasoning &&
|
|
731
|
+
reasoning_effort == o.reasoning_effort &&
|
|
669
732
|
seed == o.seed &&
|
|
670
733
|
stop == o.stop &&
|
|
671
734
|
stop_token_ids == o.stop_token_ids &&
|
|
@@ -691,7 +754,7 @@ module VeniceClient
|
|
|
691
754
|
# Calculates hash code according to all attributes.
|
|
692
755
|
# @return [Integer] Hash code
|
|
693
756
|
def hash
|
|
694
|
-
[frequency_penalty, logprobs, top_logprobs, max_completion_tokens, max_temp, max_tokens, messages, min_p, min_temp, model, n, presence_penalty, repetition_penalty, seed, stop, stop_token_ids, stream, stream_options, temperature, top_k, top_p, user, venice_parameters, parallel_tool_calls, response_format, tool_choice, tools].hash
|
|
757
|
+
[frequency_penalty, logprobs, top_logprobs, max_completion_tokens, max_temp, max_tokens, messages, min_p, min_temp, model, n, presence_penalty, prompt_cache_key, repetition_penalty, reasoning, reasoning_effort, seed, stop, stop_token_ids, stream, stream_options, temperature, top_k, top_p, user, venice_parameters, parallel_tool_calls, response_format, tool_choice, tools].hash
|
|
695
758
|
end
|
|
696
759
|
|
|
697
760
|
# Builds the object from hash
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
#The Venice.ai API.
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document:
|
|
6
|
+
The version of the OpenAPI document: 20251209.153516
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.14.0
|
|
@@ -89,7 +89,7 @@ module VeniceClient
|
|
|
89
89
|
return model if model
|
|
90
90
|
else
|
|
91
91
|
# raise if data contains keys that are not known to the model
|
|
92
|
-
|
|
92
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
93
93
|
model = const.build_from_hash(data)
|
|
94
94
|
return model if model
|
|
95
95
|
end
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Venice.ai API
|
|
3
|
+
|
|
4
|
+
#The Venice.ai API.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 20251209.153516
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.14.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module VeniceClient
|
|
17
|
+
# Configuration for reasoning behavior on supported models.
|
|
18
|
+
class ChatCompletionRequestReasoning
|
|
19
|
+
# Controls the reasoning effort level for supported models. Higher effort means more thorough reasoning but increased token usage. Defaults to the model configuration if not specified.
|
|
20
|
+
attr_accessor :effort
|
|
21
|
+
|
|
22
|
+
class EnumAttributeValidator
|
|
23
|
+
attr_reader :datatype
|
|
24
|
+
attr_reader :allowable_values
|
|
25
|
+
|
|
26
|
+
def initialize(datatype, allowable_values)
|
|
27
|
+
@allowable_values = allowable_values.map do |value|
|
|
28
|
+
case datatype.to_s
|
|
29
|
+
when /Integer/i
|
|
30
|
+
value.to_i
|
|
31
|
+
when /Float/i
|
|
32
|
+
value.to_f
|
|
33
|
+
else
|
|
34
|
+
value
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def valid?(value)
|
|
40
|
+
!value || allowable_values.include?(value)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
45
|
+
def self.attribute_map
|
|
46
|
+
{
|
|
47
|
+
:'effort' => :'effort'
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Returns attribute mapping this model knows about
|
|
52
|
+
def self.acceptable_attribute_map
|
|
53
|
+
attribute_map
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Returns all the JSON keys this model knows about
|
|
57
|
+
def self.acceptable_attributes
|
|
58
|
+
acceptable_attribute_map.values
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Attribute type mapping.
|
|
62
|
+
def self.openapi_types
|
|
63
|
+
{
|
|
64
|
+
:'effort' => :'String'
|
|
65
|
+
}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# List of attributes with nullable: true
|
|
69
|
+
def self.openapi_nullable
|
|
70
|
+
Set.new([
|
|
71
|
+
])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Initializes the object
|
|
75
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
76
|
+
def initialize(attributes = {})
|
|
77
|
+
if (!attributes.is_a?(Hash))
|
|
78
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `VeniceClient::ChatCompletionRequestReasoning` initialize method"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
82
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
83
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
84
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
85
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `VeniceClient::ChatCompletionRequestReasoning`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
86
|
+
end
|
|
87
|
+
h[k.to_sym] = v
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if attributes.key?(:'effort')
|
|
91
|
+
self.effort = attributes[:'effort']
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
96
|
+
# @return Array for valid properties with the reasons
|
|
97
|
+
def list_invalid_properties
|
|
98
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
99
|
+
invalid_properties = Array.new
|
|
100
|
+
invalid_properties
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Check to see if the all the properties in the model are valid
|
|
104
|
+
# @return true if the model is valid
|
|
105
|
+
def valid?
|
|
106
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
107
|
+
effort_validator = EnumAttributeValidator.new('String', ["low", "medium", "high"])
|
|
108
|
+
return false unless effort_validator.valid?(@effort)
|
|
109
|
+
true
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
113
|
+
# @param [Object] effort Object to be assigned
|
|
114
|
+
def effort=(effort)
|
|
115
|
+
validator = EnumAttributeValidator.new('String', ["low", "medium", "high"])
|
|
116
|
+
unless validator.valid?(effort)
|
|
117
|
+
fail ArgumentError, "invalid value for \"effort\", must be one of #{validator.allowable_values}."
|
|
118
|
+
end
|
|
119
|
+
@effort = effort
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Checks equality by comparing each attribute.
|
|
123
|
+
# @param [Object] Object to be compared
|
|
124
|
+
def ==(o)
|
|
125
|
+
return true if self.equal?(o)
|
|
126
|
+
self.class == o.class &&
|
|
127
|
+
effort == o.effort
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# @see the `==` method
|
|
131
|
+
# @param [Object] Object to be compared
|
|
132
|
+
def eql?(o)
|
|
133
|
+
self == o
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Calculates hash code according to all attributes.
|
|
137
|
+
# @return [Integer] Hash code
|
|
138
|
+
def hash
|
|
139
|
+
[effort].hash
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Builds the object from hash
|
|
143
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
144
|
+
# @return [Object] Returns the model itself
|
|
145
|
+
def self.build_from_hash(attributes)
|
|
146
|
+
return nil unless attributes.is_a?(Hash)
|
|
147
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
148
|
+
transformed_hash = {}
|
|
149
|
+
openapi_types.each_pair do |key, type|
|
|
150
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
151
|
+
transformed_hash["#{key}"] = nil
|
|
152
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
153
|
+
# check to ensure the input is an array given that the attribute
|
|
154
|
+
# is documented as an array but the input is not
|
|
155
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
156
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
157
|
+
end
|
|
158
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
159
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
new(transformed_hash)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Deserializes the data based on type
|
|
166
|
+
# @param string type Data type
|
|
167
|
+
# @param string value Value to be deserialized
|
|
168
|
+
# @return [Object] Deserialized data
|
|
169
|
+
def self._deserialize(type, value)
|
|
170
|
+
case type.to_sym
|
|
171
|
+
when :Time
|
|
172
|
+
Time.parse(value)
|
|
173
|
+
when :Date
|
|
174
|
+
Date.parse(value)
|
|
175
|
+
when :String
|
|
176
|
+
value.to_s
|
|
177
|
+
when :Integer
|
|
178
|
+
value.to_i
|
|
179
|
+
when :Float
|
|
180
|
+
value.to_f
|
|
181
|
+
when :Boolean
|
|
182
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
183
|
+
true
|
|
184
|
+
else
|
|
185
|
+
false
|
|
186
|
+
end
|
|
187
|
+
when :Object
|
|
188
|
+
# generic object (usually a Hash), return directly
|
|
189
|
+
value
|
|
190
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
191
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
192
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
193
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
194
|
+
k_type = Regexp.last_match[:k_type]
|
|
195
|
+
v_type = Regexp.last_match[:v_type]
|
|
196
|
+
{}.tap do |hash|
|
|
197
|
+
value.each do |k, v|
|
|
198
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
else # model
|
|
202
|
+
# models (e.g. Pet) or oneOf
|
|
203
|
+
klass = VeniceClient.const_get(type)
|
|
204
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Returns the string representation of the object
|
|
209
|
+
# @return [String] String presentation of the object
|
|
210
|
+
def to_s
|
|
211
|
+
to_hash.to_s
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
215
|
+
# @return [Hash] Returns the object in the form of hash
|
|
216
|
+
def to_body
|
|
217
|
+
to_hash
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Returns the object in the form of hash
|
|
221
|
+
# @return [Hash] Returns the object in the form of hash
|
|
222
|
+
def to_hash
|
|
223
|
+
hash = {}
|
|
224
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
225
|
+
value = self.send(attr)
|
|
226
|
+
if value.nil?
|
|
227
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
228
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
hash[param] = _to_hash(value)
|
|
232
|
+
end
|
|
233
|
+
hash
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# Outputs non-array value in the form of hash
|
|
237
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
238
|
+
# @param [Object] value Any valid value
|
|
239
|
+
# @return [Hash] Returns the value in the form of hash
|
|
240
|
+
def _to_hash(value)
|
|
241
|
+
if value.is_a?(Array)
|
|
242
|
+
value.compact.map { |v| _to_hash(v) }
|
|
243
|
+
elsif value.is_a?(Hash)
|
|
244
|
+
{}.tap do |hash|
|
|
245
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
246
|
+
end
|
|
247
|
+
elsif value.respond_to? :to_hash
|
|
248
|
+
value.to_hash
|
|
249
|
+
else
|
|
250
|
+
value
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
end
|