azure_openai_client 0.0.1 → 0.0.3

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.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -0
  3. data/Gemfile.lock +76 -0
  4. data/README.md +50 -87
  5. data/Rakefile +10 -0
  6. data/azure_openai_client.gemspec +38 -0
  7. data/docs/ChatCompletionsCreate200Response.md +28 -0
  8. data/docs/ChatCompletionsCreate200ResponseChoicesInner.md +22 -0
  9. data/docs/ChatCompletionsCreate200ResponseChoicesInnerMessage.md +20 -0
  10. data/docs/ChatCompletionsCreate200ResponseUsage.md +22 -0
  11. data/docs/ChatCompletionsCreateRequest.md +38 -0
  12. data/docs/ChatCompletionsCreateRequestMessagesInner.md +22 -0
  13. data/docs/ChatCompletionsCreateRequestStop.md +49 -0
  14. data/docs/CompletionsCreate200Response.md +28 -0
  15. data/docs/CompletionsCreate200ResponseChoicesInner.md +24 -0
  16. data/docs/CompletionsCreate200ResponseChoicesInnerLogprobs.md +24 -0
  17. data/docs/CompletionsCreate200ResponseUsage.md +22 -0
  18. data/docs/CompletionsCreateRequest.md +52 -0
  19. data/docs/CompletionsCreateRequestPrompt.md +49 -0
  20. data/docs/CompletionsCreateRequestStop.md +49 -0
  21. data/docs/DefaultApi.md +238 -0
  22. data/docs/EmbeddingsCreate200Response.md +24 -0
  23. data/docs/EmbeddingsCreate200ResponseDataInner.md +22 -0
  24. data/docs/EmbeddingsCreate200ResponseUsage.md +20 -0
  25. data/docs/EmbeddingsCreateRequest.md +24 -0
  26. data/docs/EmbeddingsCreateRequestInput.md +49 -0
  27. data/docs/ErrorResponse.md +18 -0
  28. data/docs/ErrorResponseError.md +24 -0
  29. data/git_push.sh +53 -0
  30. data/inference.json +816 -0
  31. data/lib/azure_openai_client/api/default_api.rb +120 -93
  32. data/lib/azure_openai_client/api_client.rb +77 -75
  33. data/lib/azure_openai_client/api_error.rb +5 -5
  34. data/lib/azure_openai_client/configuration.rb +114 -22
  35. data/lib/azure_openai_client/models/{inline_response_200_2.rb → chat_completions_create200_response.rb} +34 -26
  36. data/lib/azure_openai_client/models/{inline_response_200_2_choices.rb → chat_completions_create200_response_choices_inner.rb} +28 -20
  37. data/lib/azure_openai_client/models/{inline_response_200_2_message.rb → chat_completions_create200_response_choices_inner_message.rb} +28 -20
  38. data/lib/azure_openai_client/models/{inline_response_200_2_usage.rb → chat_completions_create200_response_usage.rb} +28 -20
  39. data/lib/azure_openai_client/models/{chat_completions_body.rb → chat_completions_create_request.rb} +183 -37
  40. data/lib/azure_openai_client/models/{deploymentsdeploymentidchatcompletions_messages.rb → chat_completions_create_request_messages_inner.rb} +30 -22
  41. data/lib/azure_openai_client/models/chat_completions_create_request_stop.rb +105 -0
  42. data/lib/azure_openai_client/models/{inline_response_200.rb → completions_create200_response.rb} +34 -26
  43. data/lib/azure_openai_client/models/{inline_response_200_choices.rb → completions_create200_response_choices_inner.rb} +30 -22
  44. data/lib/azure_openai_client/models/{inline_response_200_logprobs.rb → completions_create200_response_choices_inner_logprobs.rb} +30 -22
  45. data/lib/azure_openai_client/models/{inline_response_200_usage.rb → completions_create200_response_usage.rb} +28 -20
  46. data/lib/azure_openai_client/models/{deploymentid_completions_body.rb → completions_create_request.rb} +58 -52
  47. data/lib/azure_openai_client/models/completions_create_request_prompt.rb +105 -0
  48. data/lib/azure_openai_client/models/completions_create_request_stop.rb +105 -0
  49. data/lib/azure_openai_client/models/{inline_response_200_1.rb → embeddings_create200_response.rb} +30 -22
  50. data/lib/azure_openai_client/models/{inline_response_200_1_data.rb → embeddings_create200_response_data_inner.rb} +28 -20
  51. data/lib/azure_openai_client/models/{inline_response_200_1_usage.rb → embeddings_create200_response_usage.rb} +26 -18
  52. data/lib/azure_openai_client/models/embeddings_create_request.rb +252 -0
  53. data/lib/azure_openai_client/models/embeddings_create_request_input.rb +105 -0
  54. data/lib/azure_openai_client/models/error_response.rb +21 -13
  55. data/lib/azure_openai_client/models/error_response_error.rb +27 -19
  56. data/lib/azure_openai_client/version.rb +5 -6
  57. data/lib/azure_openai_client.rb +23 -23
  58. data/openapi-codegen.sh +12 -0
  59. data/openapi_config.yaml +15 -0
  60. data/spec/api/default_api_spec.rb +21 -22
  61. data/spec/api_client_spec.rb +15 -16
  62. data/spec/configuration_spec.rb +3 -3
  63. data/spec/models/chat_completions_create200_response_choices_inner_message_spec.rb +44 -0
  64. data/spec/models/chat_completions_create200_response_choices_inner_spec.rb +46 -0
  65. data/spec/models/chat_completions_create200_response_spec.rb +64 -0
  66. data/spec/models/chat_completions_create200_response_usage_spec.rb +46 -0
  67. data/spec/models/chat_completions_create_request_messages_inner_spec.rb +50 -0
  68. data/spec/models/chat_completions_create_request_spec.rb +94 -0
  69. data/spec/models/chat_completions_create_request_stop_spec.rb +31 -0
  70. data/spec/models/completions_create200_response_choices_inner_logprobs_spec.rb +52 -0
  71. data/spec/models/completions_create200_response_choices_inner_spec.rb +52 -0
  72. data/spec/models/completions_create200_response_spec.rb +64 -0
  73. data/spec/models/completions_create200_response_usage_spec.rb +46 -0
  74. data/spec/models/completions_create_request_prompt_spec.rb +31 -0
  75. data/spec/models/completions_create_request_spec.rb +136 -0
  76. data/spec/models/completions_create_request_stop_spec.rb +31 -0
  77. data/spec/models/embeddings_create200_response_data_inner_spec.rb +46 -0
  78. data/spec/models/embeddings_create200_response_spec.rb +52 -0
  79. data/spec/models/embeddings_create200_response_usage_spec.rb +40 -0
  80. data/spec/models/embeddings_create_request_input_spec.rb +31 -0
  81. data/spec/models/embeddings_create_request_spec.rb +52 -0
  82. data/spec/models/error_response_error_spec.rb +12 -20
  83. data/spec/models/error_response_spec.rb +9 -17
  84. data/spec/spec_helper.rb +4 -5
  85. metadata +91 -77
  86. data/lib/azure_openai_client/models/deploymentid_embeddings_body.rb +0 -202
  87. data/lib/azure_openai_client/models/one_ofchat_completions_body_stop.rb +0 -198
  88. data/lib/azure_openai_client/models/one_ofdeploymentid_completions_body_prompt.rb +0 -198
  89. data/lib/azure_openai_client/models/one_ofdeploymentid_completions_body_stop.rb +0 -198
  90. data/spec/models/chat_completions_body_spec.rb +0 -102
  91. data/spec/models/deploymentid_completions_body_spec.rb +0 -144
  92. data/spec/models/deploymentid_embeddings_body_spec.rb +0 -36
  93. data/spec/models/deploymentsdeploymentidchatcompletions_messages_spec.rb +0 -58
  94. data/spec/models/inline_response_200_1_data_spec.rb +0 -54
  95. data/spec/models/inline_response_200_1_spec.rb +0 -60
  96. data/spec/models/inline_response_200_1_usage_spec.rb +0 -48
  97. data/spec/models/inline_response_200_2_choices_spec.rb +0 -54
  98. data/spec/models/inline_response_200_2_message_spec.rb +0 -52
  99. data/spec/models/inline_response_200_2_spec.rb +0 -72
  100. data/spec/models/inline_response_200_2_usage_spec.rb +0 -54
  101. data/spec/models/inline_response_200_choices_spec.rb +0 -60
  102. data/spec/models/inline_response_200_logprobs_spec.rb +0 -60
  103. data/spec/models/inline_response_200_spec.rb +0 -72
  104. data/spec/models/inline_response_200_usage_spec.rb +0 -54
  105. data/spec/models/one_ofchat_completions_body_stop_spec.rb +0 -36
  106. data/spec/models/one_ofdeploymentid_completions_body_prompt_spec.rb +0 -36
  107. data/spec/models/one_ofdeploymentid_completions_body_stop_spec.rb +0 -36
@@ -1,14 +1,13 @@
1
- # frozen_string_literal: true
2
-
3
1
  =begin
4
2
  #Azure OpenAI Service API
5
3
 
6
4
  #Azure OpenAI APIs for completions and search
7
5
 
8
- OpenAPI spec version: 2023-05-15
6
+ The version of the OpenAPI document: 2023-05-15
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
9
10
 
10
- Generated by: https://github.com/swagger-api/swagger-codegen.git
11
- Swagger Codegen version: 3.0.42
12
11
  =end
13
12
 
14
13
  module AzureOpenaiClient
@@ -22,6 +21,18 @@ module AzureOpenaiClient
22
21
  # Defines url base path
23
22
  attr_accessor :base_path
24
23
 
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
25
36
  # Defines API keys used with API Key authentications.
26
37
  #
27
38
  # @return [Hash] key: parameter name, value: parameter value (API key)
@@ -51,6 +62,16 @@ module AzureOpenaiClient
51
62
  # Defines the access token (Bearer) used with OAuth2.
52
63
  attr_accessor :access_token
53
64
 
65
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
66
+ # Overrides the access_token if set
67
+ # @return [Proc]
68
+ attr_accessor :access_token_getter
69
+
70
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
71
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
72
+ # Default to false.
73
+ attr_accessor :return_binary_data
74
+
54
75
  # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
55
76
  # details will be logged with `logger.debug` (see the `logger` attribute).
56
77
  # Default to false.
@@ -122,23 +143,28 @@ module AzureOpenaiClient
122
143
  # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
123
144
  attr_accessor :params_encoding
124
145
 
146
+
125
147
  attr_accessor :inject_format
126
148
 
127
149
  attr_accessor :force_ending_format
128
150
 
129
151
  def initialize
130
152
  @scheme = 'https'
131
- @host = '{endpoint}'
132
- @base_path = 'https://{endpoint}/openai'
153
+ @host = 'your-resource-name.openai.azure.com'
154
+ @base_path = '/openai'
155
+ @server_index = 0
156
+ @server_operation_index = {}
157
+ @server_variables = {}
158
+ @server_operation_variables = {}
133
159
  @api_key = {}
134
160
  @api_key_prefix = {}
135
- @timeout = 0
136
161
  @client_side_validation = true
137
162
  @verify_ssl = true
138
163
  @verify_ssl_host = true
139
- @params_encoding = nil
140
164
  @cert_file = nil
141
165
  @key_file = nil
166
+ @timeout = 0
167
+ @params_encoding = nil
142
168
  @debugging = false
143
169
  @inject_format = false
144
170
  @force_ending_format = false
@@ -172,20 +198,32 @@ module AzureOpenaiClient
172
198
  @base_path = '' if @base_path == '/'
173
199
  end
174
200
 
175
- def base_url
176
- "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
201
+ # Returns base URL for specified operation based on server settings
202
+ def base_url(operation = nil)
203
+ index = server_operation_index[operation]
204
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
205
+
206
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
177
207
  end
178
208
 
179
209
  # Gets API key (with prefix if set).
180
210
  # @param [String] param_name the parameter name of API key auth
181
- def api_key_with_prefix(param_name)
211
+ def api_key_with_prefix(param_name, param_alias = nil)
212
+ key = @api_key[param_name]
213
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
182
214
  if @api_key_prefix[param_name]
183
- "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
215
+ "#{@api_key_prefix[param_name]} #{key}"
184
216
  else
185
- @api_key[param_name]
217
+ key
186
218
  end
187
219
  end
188
220
 
221
+ # Gets access_token using access_token_getter or uses the static access_token
222
+ def access_token_with_refresh
223
+ return access_token if access_token_getter.nil?
224
+ access_token_getter.call
225
+ end
226
+
189
227
  # Gets Basic Auth token string
190
228
  def basic_auth_token
191
229
  'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
@@ -194,21 +232,75 @@ module AzureOpenaiClient
194
232
  # Returns Auth Settings hash for api client.
195
233
  def auth_settings
196
234
  {
197
- 'apiKey' =>
198
- {
199
- type: 'api_key',
200
- in: 'header',
201
- key: 'api-key',
202
- value: api_key_with_prefix('api-key')
203
- },
204
235
  'bearer' =>
205
236
  {
206
237
  type: 'oauth2',
207
238
  in: 'header',
208
239
  key: 'Authorization',
209
- value: "Bearer #{access_token}"
240
+ value: "Bearer #{access_token_with_refresh}"
241
+ },
242
+ 'apiKey' =>
243
+ {
244
+ type: 'api_key',
245
+ in: 'header',
246
+ key: 'api-key',
247
+ value: api_key_with_prefix('apiKey')
210
248
  },
211
249
  }
212
250
  end
251
+
252
+ # Returns an array of Server setting
253
+ def server_settings
254
+ [
255
+ {
256
+ url: "https://{endpoint}/openai",
257
+ description: "No description provided",
258
+ variables: {
259
+ endpoint: {
260
+ description: "No description provided",
261
+ default_value: "your-resource-name.openai.azure.com",
262
+ }
263
+ }
264
+ }
265
+ ]
266
+ end
267
+
268
+ def operation_server_settings
269
+ {}
270
+ end
271
+
272
+ # Returns URL based on server settings
273
+ #
274
+ # @param index array index of the server settings
275
+ # @param variables hash of variable and the corresponding value
276
+ def server_url(index, variables = {}, servers = nil)
277
+ servers = server_settings if servers == nil
278
+
279
+ # check array index out of bound
280
+ if (index < 0 || index >= servers.size)
281
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
282
+ end
283
+
284
+ server = servers[index]
285
+ url = server[:url]
286
+
287
+ return url unless server.key? :variables
288
+
289
+ # go through variable and assign a value
290
+ server[:variables].each do |name, variable|
291
+ if variables.key?(name)
292
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
293
+ url.gsub! "{" + name.to_s + "}", variables[name]
294
+ else
295
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
296
+ end
297
+ else
298
+ # use default value
299
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
300
+ end
301
+ end
302
+
303
+ url
304
+ end
213
305
  end
214
306
  end
@@ -1,20 +1,20 @@
1
- # frozen_string_literal: true
2
-
3
1
  =begin
4
2
  #Azure OpenAI Service API
5
3
 
6
4
  #Azure OpenAI APIs for completions and search
7
5
 
8
- OpenAPI spec version: 2023-05-15
6
+ The version of the OpenAPI document: 2023-05-15
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
9
10
 
10
- Generated by: https://github.com/swagger-api/swagger-codegen.git
11
- Swagger Codegen version: 3.0.42
12
11
  =end
13
12
 
14
13
  require 'date'
14
+ require 'time'
15
15
 
16
16
  module AzureOpenaiClient
17
- class InlineResponse2002
17
+ class ChatCompletionsCreate200Response
18
18
  attr_accessor :id
19
19
 
20
20
  attr_accessor :object
@@ -30,24 +30,29 @@ module AzureOpenaiClient
30
30
  # Attribute mapping from ruby-style variable name to JSON key.
31
31
  def self.attribute_map
32
32
  {
33
- 'id': :'id',
34
- 'object': :'object',
35
- 'created': :'created',
36
- 'model': :'model',
37
- 'choices': :'choices',
38
- 'usage': :'usage'
33
+ :'id' => :'id',
34
+ :'object' => :'object',
35
+ :'created' => :'created',
36
+ :'model' => :'model',
37
+ :'choices' => :'choices',
38
+ :'usage' => :'usage'
39
39
  }
40
40
  end
41
41
 
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ attribute_map.values
45
+ end
46
+
42
47
  # Attribute type mapping.
43
48
  def self.openapi_types
44
49
  {
45
- 'id': :'Object',
46
- 'object': :'Object',
47
- 'created': :'Object',
48
- 'model': :'Object',
49
- 'choices': :'Object',
50
- 'usage': :'Object'
50
+ :'id' => :'String',
51
+ :'object' => :'String',
52
+ :'created' => :'Integer',
53
+ :'model' => :'String',
54
+ :'choices' => :'Array<ChatCompletionsCreate200ResponseChoicesInner>',
55
+ :'usage' => :'ChatCompletionsCreate200ResponseUsage'
51
56
  }
52
57
  end
53
58
 
@@ -61,13 +66,13 @@ module AzureOpenaiClient
61
66
  # @param [Hash] attributes Model attributes in the form of hash
62
67
  def initialize(attributes = {})
63
68
  if (!attributes.is_a?(Hash))
64
- fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::InlineResponse2002` initialize method"
69
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::ChatCompletionsCreate200Response` initialize method"
65
70
  end
66
71
 
67
72
  # check to see if the attribute exists and convert string to symbol for hash key
68
73
  attributes = attributes.each_with_object({}) { |(k, v), h|
69
74
  if (!self.class.attribute_map.key?(k.to_sym))
70
- fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::InlineResponse2002`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
75
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::ChatCompletionsCreate200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
76
  end
72
77
  h[k.to_sym] = v
73
78
  }
@@ -174,8 +179,11 @@ module AzureOpenaiClient
174
179
  # @return [Object] Returns the model itself
175
180
  def build_from_hash(attributes)
176
181
  return nil unless attributes.is_a?(Hash)
182
+ attributes = attributes.transform_keys(&:to_sym)
177
183
  self.class.openapi_types.each_pair do |key, type|
178
- if type =~ /\AArray<(.*)>/i
184
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
185
+ self.send("#{key}=", nil)
186
+ elsif type =~ /\AArray<(.*)>/i
179
187
  # check to ensure the input is an array given that the attribute
180
188
  # is documented as an array but the input is not
181
189
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -183,8 +191,6 @@ module AzureOpenaiClient
183
191
  end
184
192
  elsif !attributes[self.class.attribute_map[key]].nil?
185
193
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
186
- elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
187
- self.send("#{key}=", nil)
188
194
  end
189
195
  end
190
196
 
@@ -197,8 +203,8 @@ module AzureOpenaiClient
197
203
  # @return [Object] Deserialized data
198
204
  def _deserialize(type, value)
199
205
  case type.to_sym
200
- when :DateTime
201
- DateTime.parse(value)
206
+ when :Time
207
+ Time.parse(value)
202
208
  when :Date
203
209
  Date.parse(value)
204
210
  when :String
@@ -228,7 +234,9 @@ module AzureOpenaiClient
228
234
  end
229
235
  end
230
236
  else # model
231
- AzureOpenaiClient.const_get(type).build_from_hash(value)
237
+ # models (e.g. Pet) or oneOf
238
+ klass = AzureOpenaiClient.const_get(type)
239
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
232
240
  end
233
241
  end
234
242
 
@@ -1,20 +1,20 @@
1
- # frozen_string_literal: true
2
-
3
1
  =begin
4
2
  #Azure OpenAI Service API
5
3
 
6
4
  #Azure OpenAI APIs for completions and search
7
5
 
8
- OpenAPI spec version: 2023-05-15
6
+ The version of the OpenAPI document: 2023-05-15
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
9
10
 
10
- Generated by: https://github.com/swagger-api/swagger-codegen.git
11
- Swagger Codegen version: 3.0.42
12
11
  =end
13
12
 
14
13
  require 'date'
14
+ require 'time'
15
15
 
16
16
  module AzureOpenaiClient
17
- class InlineResponse2002Choices
17
+ class ChatCompletionsCreate200ResponseChoicesInner
18
18
  attr_accessor :index
19
19
 
20
20
  attr_accessor :message
@@ -24,18 +24,23 @@ module AzureOpenaiClient
24
24
  # Attribute mapping from ruby-style variable name to JSON key.
25
25
  def self.attribute_map
26
26
  {
27
- 'index': :'index',
28
- 'message': :'message',
29
- 'finish_reason': :'finish_reason'
27
+ :'index' => :'index',
28
+ :'message' => :'message',
29
+ :'finish_reason' => :'finish_reason'
30
30
  }
31
31
  end
32
32
 
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
33
38
  # Attribute type mapping.
34
39
  def self.openapi_types
35
40
  {
36
- 'index': :'Object',
37
- 'message': :'Object',
38
- 'finish_reason': :'Object'
41
+ :'index' => :'Integer',
42
+ :'message' => :'ChatCompletionsCreate200ResponseChoicesInnerMessage',
43
+ :'finish_reason' => :'String'
39
44
  }
40
45
  end
41
46
 
@@ -49,13 +54,13 @@ module AzureOpenaiClient
49
54
  # @param [Hash] attributes Model attributes in the form of hash
50
55
  def initialize(attributes = {})
51
56
  if (!attributes.is_a?(Hash))
52
- fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::InlineResponse2002Choices` initialize method"
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::ChatCompletionsCreate200ResponseChoicesInner` initialize method"
53
58
  end
54
59
 
55
60
  # check to see if the attribute exists and convert string to symbol for hash key
56
61
  attributes = attributes.each_with_object({}) { |(k, v), h|
57
62
  if (!self.class.attribute_map.key?(k.to_sym))
58
- fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::InlineResponse2002Choices`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::ChatCompletionsCreate200ResponseChoicesInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
59
64
  end
60
65
  h[k.to_sym] = v
61
66
  }
@@ -120,8 +125,11 @@ module AzureOpenaiClient
120
125
  # @return [Object] Returns the model itself
121
126
  def build_from_hash(attributes)
122
127
  return nil unless attributes.is_a?(Hash)
128
+ attributes = attributes.transform_keys(&:to_sym)
123
129
  self.class.openapi_types.each_pair do |key, type|
124
- if type =~ /\AArray<(.*)>/i
130
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
131
+ self.send("#{key}=", nil)
132
+ elsif type =~ /\AArray<(.*)>/i
125
133
  # check to ensure the input is an array given that the attribute
126
134
  # is documented as an array but the input is not
127
135
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -129,8 +137,6 @@ module AzureOpenaiClient
129
137
  end
130
138
  elsif !attributes[self.class.attribute_map[key]].nil?
131
139
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
132
- elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
133
- self.send("#{key}=", nil)
134
140
  end
135
141
  end
136
142
 
@@ -143,8 +149,8 @@ module AzureOpenaiClient
143
149
  # @return [Object] Deserialized data
144
150
  def _deserialize(type, value)
145
151
  case type.to_sym
146
- when :DateTime
147
- DateTime.parse(value)
152
+ when :Time
153
+ Time.parse(value)
148
154
  when :Date
149
155
  Date.parse(value)
150
156
  when :String
@@ -174,7 +180,9 @@ module AzureOpenaiClient
174
180
  end
175
181
  end
176
182
  else # model
177
- AzureOpenaiClient.const_get(type).build_from_hash(value)
183
+ # models (e.g. Pet) or oneOf
184
+ klass = AzureOpenaiClient.const_get(type)
185
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
178
186
  end
179
187
  end
180
188
 
@@ -1,20 +1,20 @@
1
- # frozen_string_literal: true
2
-
3
1
  =begin
4
2
  #Azure OpenAI Service API
5
3
 
6
4
  #Azure OpenAI APIs for completions and search
7
5
 
8
- OpenAPI spec version: 2023-05-15
6
+ The version of the OpenAPI document: 2023-05-15
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
9
10
 
10
- Generated by: https://github.com/swagger-api/swagger-codegen.git
11
- Swagger Codegen version: 3.0.42
12
11
  =end
13
12
 
14
13
  require 'date'
14
+ require 'time'
15
15
 
16
16
  module AzureOpenaiClient
17
- class InlineResponse2002Message
17
+ class ChatCompletionsCreate200ResponseChoicesInnerMessage
18
18
  # The role of the author of this message.
19
19
  attr_accessor :role
20
20
 
@@ -46,16 +46,21 @@ module AzureOpenaiClient
46
46
  # Attribute mapping from ruby-style variable name to JSON key.
47
47
  def self.attribute_map
48
48
  {
49
- 'role': :'role',
50
- 'content': :'content'
49
+ :'role' => :'role',
50
+ :'content' => :'content'
51
51
  }
52
52
  end
53
53
 
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
54
59
  # Attribute type mapping.
55
60
  def self.openapi_types
56
61
  {
57
- 'role': :'Object',
58
- 'content': :'Object'
62
+ :'role' => :'String',
63
+ :'content' => :'String'
59
64
  }
60
65
  end
61
66
 
@@ -69,13 +74,13 @@ module AzureOpenaiClient
69
74
  # @param [Hash] attributes Model attributes in the form of hash
70
75
  def initialize(attributes = {})
71
76
  if (!attributes.is_a?(Hash))
72
- fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::InlineResponse2002Message` initialize method"
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::ChatCompletionsCreate200ResponseChoicesInnerMessage` initialize method"
73
78
  end
74
79
 
75
80
  # check to see if the attribute exists and convert string to symbol for hash key
76
81
  attributes = attributes.each_with_object({}) { |(k, v), h|
77
82
  if (!self.class.attribute_map.key?(k.to_sym))
78
- fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::InlineResponse2002Message`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::ChatCompletionsCreate200ResponseChoicesInnerMessage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
79
84
  end
80
85
  h[k.to_sym] = v
81
86
  }
@@ -108,7 +113,7 @@ module AzureOpenaiClient
108
113
  # @return true if the model is valid
109
114
  def valid?
110
115
  return false if @role.nil?
111
- role_validator = EnumAttributeValidator.new('Object', ['system', 'user', 'assistant'])
116
+ role_validator = EnumAttributeValidator.new('String', ["system", "user", "assistant"])
112
117
  return false unless role_validator.valid?(@role)
113
118
  return false if @content.nil?
114
119
  true
@@ -117,7 +122,7 @@ module AzureOpenaiClient
117
122
  # Custom attribute writer method checking allowed values (enum).
118
123
  # @param [Object] role Object to be assigned
119
124
  def role=(role)
120
- validator = EnumAttributeValidator.new('Object', ['system', 'user', 'assistant'])
125
+ validator = EnumAttributeValidator.new('String', ["system", "user", "assistant"])
121
126
  unless validator.valid?(role)
122
127
  fail ArgumentError, "invalid value for \"role\", must be one of #{validator.allowable_values}."
123
128
  end
@@ -157,8 +162,11 @@ module AzureOpenaiClient
157
162
  # @return [Object] Returns the model itself
158
163
  def build_from_hash(attributes)
159
164
  return nil unless attributes.is_a?(Hash)
165
+ attributes = attributes.transform_keys(&:to_sym)
160
166
  self.class.openapi_types.each_pair do |key, type|
161
- if type =~ /\AArray<(.*)>/i
167
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
168
+ self.send("#{key}=", nil)
169
+ elsif type =~ /\AArray<(.*)>/i
162
170
  # check to ensure the input is an array given that the attribute
163
171
  # is documented as an array but the input is not
164
172
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -166,8 +174,6 @@ module AzureOpenaiClient
166
174
  end
167
175
  elsif !attributes[self.class.attribute_map[key]].nil?
168
176
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
169
- elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
170
- self.send("#{key}=", nil)
171
177
  end
172
178
  end
173
179
 
@@ -180,8 +186,8 @@ module AzureOpenaiClient
180
186
  # @return [Object] Deserialized data
181
187
  def _deserialize(type, value)
182
188
  case type.to_sym
183
- when :DateTime
184
- DateTime.parse(value)
189
+ when :Time
190
+ Time.parse(value)
185
191
  when :Date
186
192
  Date.parse(value)
187
193
  when :String
@@ -211,7 +217,9 @@ module AzureOpenaiClient
211
217
  end
212
218
  end
213
219
  else # model
214
- AzureOpenaiClient.const_get(type).build_from_hash(value)
220
+ # models (e.g. Pet) or oneOf
221
+ klass = AzureOpenaiClient.const_get(type)
222
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
215
223
  end
216
224
  end
217
225