openapi_openai 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +72 -0
  4. data/README.md +171 -0
  5. data/Rakefile +10 -0
  6. data/bin/bundle +109 -0
  7. data/bin/byebug +27 -0
  8. data/bin/coderay +27 -0
  9. data/bin/htmldiff +27 -0
  10. data/bin/ldiff +27 -0
  11. data/bin/pry +27 -0
  12. data/bin/racc +27 -0
  13. data/bin/rake +27 -0
  14. data/bin/rspec +27 -0
  15. data/bin/rubocop +27 -0
  16. data/bin/ruby-parse +27 -0
  17. data/bin/ruby-rewrite +27 -0
  18. data/docs/ChatCompletionFunctions.md +22 -0
  19. data/docs/ChatCompletionRequestMessage.md +24 -0
  20. data/docs/ChatCompletionRequestMessageFunctionCall.md +20 -0
  21. data/docs/ChatCompletionResponseMessage.md +22 -0
  22. data/docs/ChatCompletionStreamResponseDelta.md +22 -0
  23. data/docs/CreateChatCompletionRequest.md +44 -0
  24. data/docs/CreateChatCompletionRequestFunctionCall.md +49 -0
  25. data/docs/CreateChatCompletionRequestFunctionCallOneOf.md +18 -0
  26. data/docs/CreateChatCompletionRequestModel.md +47 -0
  27. data/docs/CreateChatCompletionRequestStop.md +49 -0
  28. data/docs/CreateChatCompletionResponse.md +28 -0
  29. data/docs/CreateChatCompletionResponseChoicesInner.md +22 -0
  30. data/docs/CreateChatCompletionStreamResponse.md +26 -0
  31. data/docs/CreateChatCompletionStreamResponseChoicesInner.md +22 -0
  32. data/docs/CreateCompletionRequest.md +48 -0
  33. data/docs/CreateCompletionRequestModel.md +47 -0
  34. data/docs/CreateCompletionRequestPrompt.md +53 -0
  35. data/docs/CreateCompletionRequestStop.md +49 -0
  36. data/docs/CreateCompletionResponse.md +28 -0
  37. data/docs/CreateCompletionResponseChoicesInner.md +24 -0
  38. data/docs/CreateCompletionResponseChoicesInnerLogprobs.md +24 -0
  39. data/docs/CreateCompletionResponseUsage.md +22 -0
  40. data/docs/CreateEditRequest.md +28 -0
  41. data/docs/CreateEditRequestModel.md +47 -0
  42. data/docs/CreateEditResponse.md +24 -0
  43. data/docs/CreateEditResponseChoicesInner.md +24 -0
  44. data/docs/CreateEmbeddingRequest.md +22 -0
  45. data/docs/CreateEmbeddingRequestInput.md +53 -0
  46. data/docs/CreateEmbeddingRequestModel.md +47 -0
  47. data/docs/CreateEmbeddingResponse.md +24 -0
  48. data/docs/CreateEmbeddingResponseDataInner.md +22 -0
  49. data/docs/CreateEmbeddingResponseUsage.md +20 -0
  50. data/docs/CreateFineTuneRequest.md +40 -0
  51. data/docs/CreateFineTuneRequestModel.md +47 -0
  52. data/docs/CreateImageRequest.md +26 -0
  53. data/docs/CreateModerationRequest.md +20 -0
  54. data/docs/CreateModerationRequestInput.md +49 -0
  55. data/docs/CreateModerationRequestModel.md +47 -0
  56. data/docs/CreateModerationResponse.md +22 -0
  57. data/docs/CreateModerationResponseResultsInner.md +22 -0
  58. data/docs/CreateModerationResponseResultsInnerCategories.md +30 -0
  59. data/docs/CreateModerationResponseResultsInnerCategoryScores.md +30 -0
  60. data/docs/CreateTranscriptionRequestModel.md +47 -0
  61. data/docs/CreateTranscriptionResponse.md +18 -0
  62. data/docs/CreateTranslationResponse.md +18 -0
  63. data/docs/DeleteFileResponse.md +22 -0
  64. data/docs/DeleteModelResponse.md +22 -0
  65. data/docs/Error.md +24 -0
  66. data/docs/ErrorResponse.md +18 -0
  67. data/docs/FineTune.md +42 -0
  68. data/docs/FineTuneEvent.md +24 -0
  69. data/docs/ImagesResponse.md +20 -0
  70. data/docs/ImagesResponseDataInner.md +20 -0
  71. data/docs/ListFilesResponse.md +20 -0
  72. data/docs/ListFineTuneEventsResponse.md +20 -0
  73. data/docs/ListFineTunesResponse.md +20 -0
  74. data/docs/ListModelsResponse.md +20 -0
  75. data/docs/Model.md +24 -0
  76. data/docs/OpenAIApi.md +1499 -0
  77. data/docs/OpenAIFile.md +32 -0
  78. data/git_push.sh +57 -0
  79. data/lib/openapi_openai/api/open_ai_api.rb +1583 -0
  80. data/lib/openapi_openai/api_client.rb +393 -0
  81. data/lib/openapi_openai/api_error.rb +58 -0
  82. data/lib/openapi_openai/configuration.rb +291 -0
  83. data/lib/openapi_openai/models/chat_completion_functions.rb +244 -0
  84. data/lib/openapi_openai/models/chat_completion_request_message.rb +285 -0
  85. data/lib/openapi_openai/models/chat_completion_request_message_function_call.rb +226 -0
  86. data/lib/openapi_openai/models/chat_completion_response_message.rb +276 -0
  87. data/lib/openapi_openai/models/chat_completion_stream_response_delta.rb +269 -0
  88. data/lib/openapi_openai/models/create_chat_completion_request.rb +537 -0
  89. data/lib/openapi_openai/models/create_chat_completion_request_function_call.rb +106 -0
  90. data/lib/openapi_openai/models/create_chat_completion_request_function_call_one_of.rb +222 -0
  91. data/lib/openapi_openai/models/create_chat_completion_request_model.rb +105 -0
  92. data/lib/openapi_openai/models/create_chat_completion_request_stop.rb +106 -0
  93. data/lib/openapi_openai/models/create_chat_completion_response.rb +296 -0
  94. data/lib/openapi_openai/models/create_chat_completion_response_choices_inner.rb +266 -0
  95. data/lib/openapi_openai/models/create_chat_completion_stream_response.rb +287 -0
  96. data/lib/openapi_openai/models/create_chat_completion_stream_response_choices_inner.rb +266 -0
  97. data/lib/openapi_openai/models/create_completion_request.rb +586 -0
  98. data/lib/openapi_openai/models/create_completion_request_model.rb +105 -0
  99. data/lib/openapi_openai/models/create_completion_request_prompt.rb +108 -0
  100. data/lib/openapi_openai/models/create_completion_request_stop.rb +106 -0
  101. data/lib/openapi_openai/models/create_completion_response.rb +296 -0
  102. data/lib/openapi_openai/models/create_completion_response_choices_inner.rb +299 -0
  103. data/lib/openapi_openai/models/create_completion_response_choices_inner_logprobs.rb +249 -0
  104. data/lib/openapi_openai/models/create_completion_response_usage.rb +253 -0
  105. data/lib/openapi_openai/models/create_edit_request.rb +362 -0
  106. data/lib/openapi_openai/models/create_edit_request_model.rb +105 -0
  107. data/lib/openapi_openai/models/create_edit_response.rb +271 -0
  108. data/lib/openapi_openai/models/create_edit_response_choices_inner.rb +276 -0
  109. data/lib/openapi_openai/models/create_embedding_request.rb +247 -0
  110. data/lib/openapi_openai/models/create_embedding_request_input.rb +108 -0
  111. data/lib/openapi_openai/models/create_embedding_request_model.rb +105 -0
  112. data/lib/openapi_openai/models/create_embedding_response.rb +271 -0
  113. data/lib/openapi_openai/models/create_embedding_response_data_inner.rb +255 -0
  114. data/lib/openapi_openai/models/create_embedding_response_usage.rb +237 -0
  115. data/lib/openapi_openai/models/create_fine_tune_request.rb +374 -0
  116. data/lib/openapi_openai/models/create_fine_tune_request_model.rb +105 -0
  117. data/lib/openapi_openai/models/create_image_request.rb +341 -0
  118. data/lib/openapi_openai/models/create_moderation_request.rb +230 -0
  119. data/lib/openapi_openai/models/create_moderation_request_input.rb +106 -0
  120. data/lib/openapi_openai/models/create_moderation_request_model.rb +105 -0
  121. data/lib/openapi_openai/models/create_moderation_response.rb +255 -0
  122. data/lib/openapi_openai/models/create_moderation_response_results_inner.rb +253 -0
  123. data/lib/openapi_openai/models/create_moderation_response_results_inner_categories.rb +317 -0
  124. data/lib/openapi_openai/models/create_moderation_response_results_inner_category_scores.rb +317 -0
  125. data/lib/openapi_openai/models/create_transcription_request_model.rb +105 -0
  126. data/lib/openapi_openai/models/create_transcription_response.rb +221 -0
  127. data/lib/openapi_openai/models/create_translation_response.rb +221 -0
  128. data/lib/openapi_openai/models/delete_file_response.rb +253 -0
  129. data/lib/openapi_openai/models/delete_model_response.rb +253 -0
  130. data/lib/openapi_openai/models/error.rb +261 -0
  131. data/lib/openapi_openai/models/error_response.rb +221 -0
  132. data/lib/openapi_openai/models/fine_tune.rb +410 -0
  133. data/lib/openapi_openai/models/fine_tune_event.rb +269 -0
  134. data/lib/openapi_openai/models/images_response.rb +239 -0
  135. data/lib/openapi_openai/models/images_response_data_inner.rb +223 -0
  136. data/lib/openapi_openai/models/list_files_response.rb +239 -0
  137. data/lib/openapi_openai/models/list_fine_tune_events_response.rb +239 -0
  138. data/lib/openapi_openai/models/list_fine_tunes_response.rb +239 -0
  139. data/lib/openapi_openai/models/list_models_response.rb +239 -0
  140. data/lib/openapi_openai/models/model.rb +269 -0
  141. data/lib/openapi_openai/models/open_ai_file.rb +320 -0
  142. data/lib/openapi_openai/version.rb +15 -0
  143. data/lib/openapi_openai.rb +99 -0
  144. data/openapi_openai.gemspec +39 -0
  145. data/spec/api/open_ai_api_spec.rb +306 -0
  146. data/spec/models/chat_completion_functions_spec.rb +48 -0
  147. data/spec/models/chat_completion_request_message_function_call_spec.rb +42 -0
  148. data/spec/models/chat_completion_request_message_spec.rb +58 -0
  149. data/spec/models/chat_completion_response_message_spec.rb +52 -0
  150. data/spec/models/chat_completion_stream_response_delta_spec.rb +52 -0
  151. data/spec/models/create_chat_completion_request_function_call_one_of_spec.rb +36 -0
  152. data/spec/models/create_chat_completion_request_function_call_spec.rb +32 -0
  153. data/spec/models/create_chat_completion_request_model_spec.rb +32 -0
  154. data/spec/models/create_chat_completion_request_spec.rb +114 -0
  155. data/spec/models/create_chat_completion_request_stop_spec.rb +32 -0
  156. data/spec/models/create_chat_completion_response_choices_inner_spec.rb +52 -0
  157. data/spec/models/create_chat_completion_response_spec.rb +66 -0
  158. data/spec/models/create_chat_completion_stream_response_choices_inner_spec.rb +52 -0
  159. data/spec/models/create_chat_completion_stream_response_spec.rb +60 -0
  160. data/spec/models/create_completion_request_model_spec.rb +32 -0
  161. data/spec/models/create_completion_request_prompt_spec.rb +32 -0
  162. data/spec/models/create_completion_request_spec.rb +126 -0
  163. data/spec/models/create_completion_request_stop_spec.rb +32 -0
  164. data/spec/models/create_completion_response_choices_inner_logprobs_spec.rb +54 -0
  165. data/spec/models/create_completion_response_choices_inner_spec.rb +58 -0
  166. data/spec/models/create_completion_response_spec.rb +66 -0
  167. data/spec/models/create_completion_response_usage_spec.rb +48 -0
  168. data/spec/models/create_edit_request_model_spec.rb +32 -0
  169. data/spec/models/create_edit_request_spec.rb +66 -0
  170. data/spec/models/create_edit_response_choices_inner_spec.rb +58 -0
  171. data/spec/models/create_edit_response_spec.rb +54 -0
  172. data/spec/models/create_embedding_request_input_spec.rb +32 -0
  173. data/spec/models/create_embedding_request_model_spec.rb +32 -0
  174. data/spec/models/create_embedding_request_spec.rb +48 -0
  175. data/spec/models/create_embedding_response_data_inner_spec.rb +48 -0
  176. data/spec/models/create_embedding_response_spec.rb +54 -0
  177. data/spec/models/create_embedding_response_usage_spec.rb +42 -0
  178. data/spec/models/create_fine_tune_request_model_spec.rb +32 -0
  179. data/spec/models/create_fine_tune_request_spec.rb +102 -0
  180. data/spec/models/create_image_request_spec.rb +68 -0
  181. data/spec/models/create_moderation_request_input_spec.rb +32 -0
  182. data/spec/models/create_moderation_request_model_spec.rb +32 -0
  183. data/spec/models/create_moderation_request_spec.rb +42 -0
  184. data/spec/models/create_moderation_response_results_inner_categories_spec.rb +72 -0
  185. data/spec/models/create_moderation_response_results_inner_category_scores_spec.rb +72 -0
  186. data/spec/models/create_moderation_response_results_inner_spec.rb +48 -0
  187. data/spec/models/create_moderation_response_spec.rb +48 -0
  188. data/spec/models/create_transcription_request_model_spec.rb +32 -0
  189. data/spec/models/create_transcription_response_spec.rb +36 -0
  190. data/spec/models/create_translation_response_spec.rb +36 -0
  191. data/spec/models/delete_file_response_spec.rb +48 -0
  192. data/spec/models/delete_model_response_spec.rb +48 -0
  193. data/spec/models/error_response_spec.rb +36 -0
  194. data/spec/models/error_spec.rb +54 -0
  195. data/spec/models/fine_tune_event_spec.rb +54 -0
  196. data/spec/models/fine_tune_spec.rb +108 -0
  197. data/spec/models/images_response_data_inner_spec.rb +42 -0
  198. data/spec/models/images_response_spec.rb +42 -0
  199. data/spec/models/list_files_response_spec.rb +42 -0
  200. data/spec/models/list_fine_tune_events_response_spec.rb +42 -0
  201. data/spec/models/list_fine_tunes_response_spec.rb +42 -0
  202. data/spec/models/list_models_response_spec.rb +42 -0
  203. data/spec/models/model_spec.rb +54 -0
  204. data/spec/models/open_ai_file_spec.rb +78 -0
  205. data/spec/spec_helper.rb +111 -0
  206. metadata +348 -0
@@ -0,0 +1,269 @@
1
+ =begin
2
+ #OpenAI API
3
+
4
+ #APIs for sampling from and fine-tuning language models
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: blah+oapicf@cliffano.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenApiOpenAIClient
17
+ class FineTuneEvent
18
+ attr_accessor :object
19
+
20
+ attr_accessor :created_at
21
+
22
+ attr_accessor :level
23
+
24
+ attr_accessor :message
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'object' => :'object',
30
+ :'created_at' => :'created_at',
31
+ :'level' => :'level',
32
+ :'message' => :'message'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'object' => :'String',
45
+ :'created_at' => :'Integer',
46
+ :'level' => :'String',
47
+ :'message' => :'String'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenApiOpenAIClient::FineTuneEvent` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenApiOpenAIClient::FineTuneEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'object')
73
+ self.object = attributes[:'object']
74
+ else
75
+ self.object = nil
76
+ end
77
+
78
+ if attributes.key?(:'created_at')
79
+ self.created_at = attributes[:'created_at']
80
+ else
81
+ self.created_at = nil
82
+ end
83
+
84
+ if attributes.key?(:'level')
85
+ self.level = attributes[:'level']
86
+ else
87
+ self.level = nil
88
+ end
89
+
90
+ if attributes.key?(:'message')
91
+ self.message = attributes[:'message']
92
+ else
93
+ self.message = nil
94
+ end
95
+ end
96
+
97
+ # Show invalid properties with the reasons. Usually used together with valid?
98
+ # @return Array for valid properties with the reasons
99
+ def list_invalid_properties
100
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
101
+ invalid_properties = Array.new
102
+ if @object.nil?
103
+ invalid_properties.push('invalid value for "object", object cannot be nil.')
104
+ end
105
+
106
+ if @created_at.nil?
107
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
108
+ end
109
+
110
+ if @level.nil?
111
+ invalid_properties.push('invalid value for "level", level cannot be nil.')
112
+ end
113
+
114
+ if @message.nil?
115
+ invalid_properties.push('invalid value for "message", message cannot be nil.')
116
+ end
117
+
118
+ invalid_properties
119
+ end
120
+
121
+ # Check to see if the all the properties in the model are valid
122
+ # @return true if the model is valid
123
+ def valid?
124
+ warn '[DEPRECATED] the `valid?` method is obsolete'
125
+ return false if @object.nil?
126
+ return false if @created_at.nil?
127
+ return false if @level.nil?
128
+ return false if @message.nil?
129
+ true
130
+ end
131
+
132
+ # Checks equality by comparing each attribute.
133
+ # @param [Object] Object to be compared
134
+ def ==(o)
135
+ return true if self.equal?(o)
136
+ self.class == o.class &&
137
+ object == o.object &&
138
+ created_at == o.created_at &&
139
+ level == o.level &&
140
+ message == o.message
141
+ end
142
+
143
+ # @see the `==` method
144
+ # @param [Object] Object to be compared
145
+ def eql?(o)
146
+ self == o
147
+ end
148
+
149
+ # Calculates hash code according to all attributes.
150
+ # @return [Integer] Hash code
151
+ def hash
152
+ [object, created_at, level, message].hash
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def self.build_from_hash(attributes)
159
+ return nil unless attributes.is_a?(Hash)
160
+ attributes = attributes.transform_keys(&:to_sym)
161
+ transformed_hash = {}
162
+ openapi_types.each_pair do |key, type|
163
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
164
+ transformed_hash["#{key}"] = nil
165
+ elsif type =~ /\AArray<(.*)>/i
166
+ # check to ensure the input is an array given that the attribute
167
+ # is documented as an array but the input is not
168
+ if attributes[attribute_map[key]].is_a?(Array)
169
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
170
+ end
171
+ elsif !attributes[attribute_map[key]].nil?
172
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
173
+ end
174
+ end
175
+ new(transformed_hash)
176
+ end
177
+
178
+ # Deserializes the data based on type
179
+ # @param string type Data type
180
+ # @param string value Value to be deserialized
181
+ # @return [Object] Deserialized data
182
+ def self._deserialize(type, value)
183
+ case type.to_sym
184
+ when :Time
185
+ Time.parse(value)
186
+ when :Date
187
+ Date.parse(value)
188
+ when :String
189
+ value.to_s
190
+ when :Integer
191
+ value.to_i
192
+ when :Float
193
+ value.to_f
194
+ when :Boolean
195
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
196
+ true
197
+ else
198
+ false
199
+ end
200
+ when :Object
201
+ # generic object (usually a Hash), return directly
202
+ value
203
+ when /\AArray<(?<inner_type>.+)>\z/
204
+ inner_type = Regexp.last_match[:inner_type]
205
+ value.map { |v| _deserialize(inner_type, v) }
206
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
207
+ k_type = Regexp.last_match[:k_type]
208
+ v_type = Regexp.last_match[:v_type]
209
+ {}.tap do |hash|
210
+ value.each do |k, v|
211
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
212
+ end
213
+ end
214
+ else # model
215
+ # models (e.g. Pet) or oneOf
216
+ klass = OpenApiOpenAIClient.const_get(type)
217
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
218
+ end
219
+ end
220
+
221
+ # Returns the string representation of the object
222
+ # @return [String] String presentation of the object
223
+ def to_s
224
+ to_hash.to_s
225
+ end
226
+
227
+ # to_body is an alias to to_hash (backward compatibility)
228
+ # @return [Hash] Returns the object in the form of hash
229
+ def to_body
230
+ to_hash
231
+ end
232
+
233
+ # Returns the object in the form of hash
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_hash
236
+ hash = {}
237
+ self.class.attribute_map.each_pair do |attr, param|
238
+ value = self.send(attr)
239
+ if value.nil?
240
+ is_nullable = self.class.openapi_nullable.include?(attr)
241
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
242
+ end
243
+
244
+ hash[param] = _to_hash(value)
245
+ end
246
+ hash
247
+ end
248
+
249
+ # Outputs non-array value in the form of hash
250
+ # For object, use to_hash. Otherwise, just return the value
251
+ # @param [Object] value Any valid value
252
+ # @return [Hash] Returns the value in the form of hash
253
+ def _to_hash(value)
254
+ if value.is_a?(Array)
255
+ value.compact.map { |v| _to_hash(v) }
256
+ elsif value.is_a?(Hash)
257
+ {}.tap do |hash|
258
+ value.each { |k, v| hash[k] = _to_hash(v) }
259
+ end
260
+ elsif value.respond_to? :to_hash
261
+ value.to_hash
262
+ else
263
+ value
264
+ end
265
+ end
266
+
267
+ end
268
+
269
+ end
@@ -0,0 +1,239 @@
1
+ =begin
2
+ #OpenAI API
3
+
4
+ #APIs for sampling from and fine-tuning language models
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: blah+oapicf@cliffano.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenApiOpenAIClient
17
+ class ImagesResponse
18
+ attr_accessor :created
19
+
20
+ attr_accessor :data
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'created' => :'created',
26
+ :'data' => :'data'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'created' => :'Integer',
39
+ :'data' => :'Array<ImagesResponseDataInner>'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenApiOpenAIClient::ImagesResponse` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenApiOpenAIClient::ImagesResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'created')
65
+ self.created = attributes[:'created']
66
+ else
67
+ self.created = nil
68
+ end
69
+
70
+ if attributes.key?(:'data')
71
+ if (value = attributes[:'data']).is_a?(Array)
72
+ self.data = value
73
+ end
74
+ else
75
+ self.data = nil
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
+ invalid_properties = Array.new
84
+ if @created.nil?
85
+ invalid_properties.push('invalid value for "created", created cannot be nil.')
86
+ end
87
+
88
+ if @data.nil?
89
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
90
+ end
91
+
92
+ invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ warn '[DEPRECATED] the `valid?` method is obsolete'
99
+ return false if @created.nil?
100
+ return false if @data.nil?
101
+ true
102
+ end
103
+
104
+ # Checks equality by comparing each attribute.
105
+ # @param [Object] Object to be compared
106
+ def ==(o)
107
+ return true if self.equal?(o)
108
+ self.class == o.class &&
109
+ created == o.created &&
110
+ data == o.data
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [created, data].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ return nil unless attributes.is_a?(Hash)
130
+ attributes = attributes.transform_keys(&:to_sym)
131
+ transformed_hash = {}
132
+ openapi_types.each_pair do |key, type|
133
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
134
+ transformed_hash["#{key}"] = nil
135
+ elsif type =~ /\AArray<(.*)>/i
136
+ # check to ensure the input is an array given that the attribute
137
+ # is documented as an array but the input is not
138
+ if attributes[attribute_map[key]].is_a?(Array)
139
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
140
+ end
141
+ elsif !attributes[attribute_map[key]].nil?
142
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
143
+ end
144
+ end
145
+ new(transformed_hash)
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def self._deserialize(type, value)
153
+ case type.to_sym
154
+ when :Time
155
+ Time.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ # models (e.g. Pet) or oneOf
186
+ klass = OpenApiOpenAIClient.const_get(type)
187
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
+ end
189
+ end
190
+
191
+ # Returns the string representation of the object
192
+ # @return [String] String presentation of the object
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_hash (backward compatibility)
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_body
200
+ to_hash
201
+ end
202
+
203
+ # Returns the object in the form of hash
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_hash
206
+ hash = {}
207
+ self.class.attribute_map.each_pair do |attr, param|
208
+ value = self.send(attr)
209
+ if value.nil?
210
+ is_nullable = self.class.openapi_nullable.include?(attr)
211
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
212
+ end
213
+
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+
237
+ end
238
+
239
+ end