azure_openai_client 0.0.1

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 (53) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +178 -0
  3. data/lib/azure_openai_client/api/default_api.rb +232 -0
  4. data/lib/azure_openai_client/api_client.rb +390 -0
  5. data/lib/azure_openai_client/api_error.rb +58 -0
  6. data/lib/azure_openai_client/configuration.rb +214 -0
  7. data/lib/azure_openai_client/models/chat_completions_body.rb +334 -0
  8. data/lib/azure_openai_client/models/deploymentid_completions_body.rb +406 -0
  9. data/lib/azure_openai_client/models/deploymentid_embeddings_body.rb +202 -0
  10. data/lib/azure_openai_client/models/deploymentsdeploymentidchatcompletions_messages.rb +274 -0
  11. data/lib/azure_openai_client/models/error_response.rb +209 -0
  12. data/lib/azure_openai_client/models/error_response_error.rb +236 -0
  13. data/lib/azure_openai_client/models/inline_response_200.rb +281 -0
  14. data/lib/azure_openai_client/models/inline_response_200_1.rb +258 -0
  15. data/lib/azure_openai_client/models/inline_response_200_1_data.rb +244 -0
  16. data/lib/azure_openai_client/models/inline_response_200_1_usage.rb +228 -0
  17. data/lib/azure_openai_client/models/inline_response_200_2.rb +281 -0
  18. data/lib/azure_openai_client/models/inline_response_200_2_choices.rb +227 -0
  19. data/lib/azure_openai_client/models/inline_response_200_2_message.rb +264 -0
  20. data/lib/azure_openai_client/models/inline_response_200_2_usage.rb +242 -0
  21. data/lib/azure_openai_client/models/inline_response_200_choices.rb +236 -0
  22. data/lib/azure_openai_client/models/inline_response_200_logprobs.rb +244 -0
  23. data/lib/azure_openai_client/models/inline_response_200_usage.rb +242 -0
  24. data/lib/azure_openai_client/models/one_ofchat_completions_body_stop.rb +198 -0
  25. data/lib/azure_openai_client/models/one_ofdeploymentid_completions_body_prompt.rb +198 -0
  26. data/lib/azure_openai_client/models/one_ofdeploymentid_completions_body_stop.rb +198 -0
  27. data/lib/azure_openai_client/version.rb +16 -0
  28. data/lib/azure_openai_client.rb +61 -0
  29. data/spec/api/default_api_spec.rb +75 -0
  30. data/spec/api_client_spec.rb +229 -0
  31. data/spec/configuration_spec.rb +78 -0
  32. data/spec/models/chat_completions_body_spec.rb +102 -0
  33. data/spec/models/deploymentid_completions_body_spec.rb +144 -0
  34. data/spec/models/deploymentid_embeddings_body_spec.rb +36 -0
  35. data/spec/models/deploymentsdeploymentidchatcompletions_messages_spec.rb +58 -0
  36. data/spec/models/error_response_error_spec.rb +60 -0
  37. data/spec/models/error_response_spec.rb +42 -0
  38. data/spec/models/inline_response_200_1_data_spec.rb +54 -0
  39. data/spec/models/inline_response_200_1_spec.rb +60 -0
  40. data/spec/models/inline_response_200_1_usage_spec.rb +48 -0
  41. data/spec/models/inline_response_200_2_choices_spec.rb +54 -0
  42. data/spec/models/inline_response_200_2_message_spec.rb +52 -0
  43. data/spec/models/inline_response_200_2_spec.rb +72 -0
  44. data/spec/models/inline_response_200_2_usage_spec.rb +54 -0
  45. data/spec/models/inline_response_200_choices_spec.rb +60 -0
  46. data/spec/models/inline_response_200_logprobs_spec.rb +60 -0
  47. data/spec/models/inline_response_200_spec.rb +72 -0
  48. data/spec/models/inline_response_200_usage_spec.rb +54 -0
  49. data/spec/models/one_ofchat_completions_body_stop_spec.rb +36 -0
  50. data/spec/models/one_ofdeploymentid_completions_body_prompt_spec.rb +36 -0
  51. data/spec/models/one_ofdeploymentid_completions_body_stop_spec.rb +36 -0
  52. data/spec/spec_helper.rb +112 -0
  53. metadata +177 -0
@@ -0,0 +1,281 @@
1
+ # frozen_string_literal: true
2
+
3
+ =begin
4
+ #Azure OpenAI Service API
5
+
6
+ #Azure OpenAI APIs for completions and search
7
+
8
+ OpenAPI spec version: 2023-05-15
9
+
10
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
11
+ Swagger Codegen version: 3.0.42
12
+ =end
13
+
14
+ require 'date'
15
+
16
+ module AzureOpenaiClient
17
+ class InlineResponse200
18
+ attr_accessor :id
19
+
20
+ attr_accessor :object
21
+
22
+ attr_accessor :created
23
+
24
+ attr_accessor :model
25
+
26
+ attr_accessor :choices
27
+
28
+ attr_accessor :usage
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ 'id': :'id',
34
+ 'object': :'object',
35
+ 'created': :'created',
36
+ 'model': :'model',
37
+ 'choices': :'choices',
38
+ 'usage': :'usage'
39
+ }
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ 'id': :'Object',
46
+ 'object': :'Object',
47
+ 'created': :'Object',
48
+ 'model': :'Object',
49
+ 'choices': :'Object',
50
+ 'usage': :'Object'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ ])
58
+ end
59
+
60
+ # Initializes the object
61
+ # @param [Hash] attributes Model attributes in the form of hash
62
+ def initialize(attributes = {})
63
+ if (!attributes.is_a?(Hash))
64
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::InlineResponse200` initialize method"
65
+ end
66
+
67
+ # check to see if the attribute exists and convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!self.class.attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::InlineResponse200`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'id')
76
+ self.id = attributes[:'id']
77
+ end
78
+
79
+ if attributes.key?(:'object')
80
+ self.object = attributes[:'object']
81
+ end
82
+
83
+ if attributes.key?(:'created')
84
+ self.created = attributes[:'created']
85
+ end
86
+
87
+ if attributes.key?(:'model')
88
+ self.model = attributes[:'model']
89
+ end
90
+
91
+ if attributes.key?(:'choices')
92
+ if (value = attributes[:'choices']).is_a?(Array)
93
+ self.choices = value
94
+ end
95
+ end
96
+
97
+ if attributes.key?(:'usage')
98
+ self.usage = attributes[:'usage']
99
+ end
100
+ end
101
+
102
+ # Show invalid properties with the reasons. Usually used together with valid?
103
+ # @return Array for valid properties with the reasons
104
+ def list_invalid_properties
105
+ invalid_properties = Array.new
106
+ if @id.nil?
107
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
108
+ end
109
+
110
+ if @object.nil?
111
+ invalid_properties.push('invalid value for "object", object cannot be nil.')
112
+ end
113
+
114
+ if @created.nil?
115
+ invalid_properties.push('invalid value for "created", created cannot be nil.')
116
+ end
117
+
118
+ if @model.nil?
119
+ invalid_properties.push('invalid value for "model", model cannot be nil.')
120
+ end
121
+
122
+ if @choices.nil?
123
+ invalid_properties.push('invalid value for "choices", choices cannot be nil.')
124
+ end
125
+
126
+ invalid_properties
127
+ end
128
+
129
+ # Check to see if the all the properties in the model are valid
130
+ # @return true if the model is valid
131
+ def valid?
132
+ return false if @id.nil?
133
+ return false if @object.nil?
134
+ return false if @created.nil?
135
+ return false if @model.nil?
136
+ return false if @choices.nil?
137
+ true
138
+ end
139
+
140
+ # Checks equality by comparing each attribute.
141
+ # @param [Object] Object to be compared
142
+ def ==(o)
143
+ return true if self.equal?(o)
144
+ self.class == o.class &&
145
+ id == o.id &&
146
+ object == o.object &&
147
+ created == o.created &&
148
+ model == o.model &&
149
+ choices == o.choices &&
150
+ usage == o.usage
151
+ end
152
+
153
+ # @see the `==` method
154
+ # @param [Object] Object to be compared
155
+ def eql?(o)
156
+ self == o
157
+ end
158
+
159
+ # Calculates hash code according to all attributes.
160
+ # @return [Integer] Hash code
161
+ def hash
162
+ [id, object, created, model, choices, usage].hash
163
+ end
164
+
165
+ # Builds the object from hash
166
+ # @param [Hash] attributes Model attributes in the form of hash
167
+ # @return [Object] Returns the model itself
168
+ def self.build_from_hash(attributes)
169
+ new.build_from_hash(attributes)
170
+ end
171
+
172
+ # Builds the object from hash
173
+ # @param [Hash] attributes Model attributes in the form of hash
174
+ # @return [Object] Returns the model itself
175
+ def build_from_hash(attributes)
176
+ return nil unless attributes.is_a?(Hash)
177
+ self.class.openapi_types.each_pair do |key, type|
178
+ if type =~ /\AArray<(.*)>/i
179
+ # check to ensure the input is an array given that the attribute
180
+ # is documented as an array but the input is not
181
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
182
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
183
+ end
184
+ elsif !attributes[self.class.attribute_map[key]].nil?
185
+ 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
+ end
189
+ end
190
+
191
+ self
192
+ end
193
+
194
+ # Deserializes the data based on type
195
+ # @param string type Data type
196
+ # @param string value Value to be deserialized
197
+ # @return [Object] Deserialized data
198
+ def _deserialize(type, value)
199
+ case type.to_sym
200
+ when :DateTime
201
+ DateTime.parse(value)
202
+ when :Date
203
+ Date.parse(value)
204
+ when :String
205
+ value.to_s
206
+ when :Integer
207
+ value.to_i
208
+ when :Float
209
+ value.to_f
210
+ when :Boolean
211
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
212
+ true
213
+ else
214
+ false
215
+ end
216
+ when :Object
217
+ # generic object (usually a Hash), return directly
218
+ value
219
+ when /\AArray<(?<inner_type>.+)>\z/
220
+ inner_type = Regexp.last_match[:inner_type]
221
+ value.map { |v| _deserialize(inner_type, v) }
222
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
223
+ k_type = Regexp.last_match[:k_type]
224
+ v_type = Regexp.last_match[:v_type]
225
+ {}.tap do |hash|
226
+ value.each do |k, v|
227
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
228
+ end
229
+ end
230
+ else # model
231
+ AzureOpenaiClient.const_get(type).build_from_hash(value)
232
+ end
233
+ end
234
+
235
+ # Returns the string representation of the object
236
+ # @return [String] String presentation of the object
237
+ def to_s
238
+ to_hash.to_s
239
+ end
240
+
241
+ # to_body is an alias to to_hash (backward compatibility)
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_body
244
+ to_hash
245
+ end
246
+
247
+ # Returns the object in the form of hash
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_hash
250
+ hash = {}
251
+ self.class.attribute_map.each_pair do |attr, param|
252
+ value = self.send(attr)
253
+ if value.nil?
254
+ is_nullable = self.class.openapi_nullable.include?(attr)
255
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
256
+ end
257
+
258
+ hash[param] = _to_hash(value)
259
+ end
260
+ hash
261
+ end
262
+
263
+ # Outputs non-array value in the form of hash
264
+ # For object, use to_hash. Otherwise, just return the value
265
+ # @param [Object] value Any valid value
266
+ # @return [Hash] Returns the value in the form of hash
267
+ def _to_hash(value)
268
+ if value.is_a?(Array)
269
+ value.compact.map { |v| _to_hash(v) }
270
+ elsif value.is_a?(Hash)
271
+ {}.tap do |hash|
272
+ value.each { |k, v| hash[k] = _to_hash(v) }
273
+ end
274
+ elsif value.respond_to? :to_hash
275
+ value.to_hash
276
+ else
277
+ value
278
+ end
279
+ end
280
+ end
281
+ end
@@ -0,0 +1,258 @@
1
+ # frozen_string_literal: true
2
+
3
+ =begin
4
+ #Azure OpenAI Service API
5
+
6
+ #Azure OpenAI APIs for completions and search
7
+
8
+ OpenAPI spec version: 2023-05-15
9
+
10
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
11
+ Swagger Codegen version: 3.0.42
12
+ =end
13
+
14
+ require 'date'
15
+
16
+ module AzureOpenaiClient
17
+ class InlineResponse2001
18
+ attr_accessor :object
19
+
20
+ attr_accessor :model
21
+
22
+ attr_accessor :data
23
+
24
+ attr_accessor :usage
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ 'object': :'object',
30
+ 'model': :'model',
31
+ 'data': :'data',
32
+ 'usage': :'usage'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ 'object': :'Object',
40
+ 'model': :'Object',
41
+ 'data': :'Object',
42
+ 'usage': :'Object'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::InlineResponse2001` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::InlineResponse2001`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'object')
68
+ self.object = attributes[:'object']
69
+ end
70
+
71
+ if attributes.key?(:'model')
72
+ self.model = attributes[:'model']
73
+ end
74
+
75
+ if attributes.key?(:'data')
76
+ if (value = attributes[:'data']).is_a?(Array)
77
+ self.data = value
78
+ end
79
+ end
80
+
81
+ if attributes.key?(:'usage')
82
+ self.usage = attributes[:'usage']
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ invalid_properties = Array.new
90
+ if @object.nil?
91
+ invalid_properties.push('invalid value for "object", object cannot be nil.')
92
+ end
93
+
94
+ if @model.nil?
95
+ invalid_properties.push('invalid value for "model", model cannot be nil.')
96
+ end
97
+
98
+ if @data.nil?
99
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
100
+ end
101
+
102
+ if @usage.nil?
103
+ invalid_properties.push('invalid value for "usage", usage cannot be nil.')
104
+ end
105
+
106
+ invalid_properties
107
+ end
108
+
109
+ # Check to see if the all the properties in the model are valid
110
+ # @return true if the model is valid
111
+ def valid?
112
+ return false if @object.nil?
113
+ return false if @model.nil?
114
+ return false if @data.nil?
115
+ return false if @usage.nil?
116
+ true
117
+ end
118
+
119
+ # Checks equality by comparing each attribute.
120
+ # @param [Object] Object to be compared
121
+ def ==(o)
122
+ return true if self.equal?(o)
123
+ self.class == o.class &&
124
+ object == o.object &&
125
+ model == o.model &&
126
+ data == o.data &&
127
+ usage == o.usage
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
+ [object, model, data, usage].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
+ new.build_from_hash(attributes)
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def build_from_hash(attributes)
153
+ return nil unless attributes.is_a?(Hash)
154
+ self.class.openapi_types.each_pair do |key, type|
155
+ if type =~ /\AArray<(.*)>/i
156
+ # check to ensure the input is an array given that the attribute
157
+ # is documented as an array but the input is not
158
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
159
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
160
+ end
161
+ elsif !attributes[self.class.attribute_map[key]].nil?
162
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
163
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
164
+ self.send("#{key}=", nil)
165
+ end
166
+ end
167
+
168
+ self
169
+ end
170
+
171
+ # Deserializes the data based on type
172
+ # @param string type Data type
173
+ # @param string value Value to be deserialized
174
+ # @return [Object] Deserialized data
175
+ def _deserialize(type, value)
176
+ case type.to_sym
177
+ when :DateTime
178
+ DateTime.parse(value)
179
+ when :Date
180
+ Date.parse(value)
181
+ when :String
182
+ value.to_s
183
+ when :Integer
184
+ value.to_i
185
+ when :Float
186
+ value.to_f
187
+ when :Boolean
188
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
189
+ true
190
+ else
191
+ false
192
+ end
193
+ when :Object
194
+ # generic object (usually a Hash), return directly
195
+ value
196
+ when /\AArray<(?<inner_type>.+)>\z/
197
+ inner_type = Regexp.last_match[:inner_type]
198
+ value.map { |v| _deserialize(inner_type, v) }
199
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
200
+ k_type = Regexp.last_match[:k_type]
201
+ v_type = Regexp.last_match[:v_type]
202
+ {}.tap do |hash|
203
+ value.each do |k, v|
204
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
205
+ end
206
+ end
207
+ else # model
208
+ AzureOpenaiClient.const_get(type).build_from_hash(value)
209
+ end
210
+ end
211
+
212
+ # Returns the string representation of the object
213
+ # @return [String] String presentation of the object
214
+ def to_s
215
+ to_hash.to_s
216
+ end
217
+
218
+ # to_body is an alias to to_hash (backward compatibility)
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_body
221
+ to_hash
222
+ end
223
+
224
+ # Returns the object in the form of hash
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_hash
227
+ hash = {}
228
+ self.class.attribute_map.each_pair do |attr, param|
229
+ value = self.send(attr)
230
+ if value.nil?
231
+ is_nullable = self.class.openapi_nullable.include?(attr)
232
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
233
+ end
234
+
235
+ hash[param] = _to_hash(value)
236
+ end
237
+ hash
238
+ end
239
+
240
+ # Outputs non-array value in the form of hash
241
+ # For object, use to_hash. Otherwise, just return the value
242
+ # @param [Object] value Any valid value
243
+ # @return [Hash] Returns the value in the form of hash
244
+ def _to_hash(value)
245
+ if value.is_a?(Array)
246
+ value.compact.map { |v| _to_hash(v) }
247
+ elsif value.is_a?(Hash)
248
+ {}.tap do |hash|
249
+ value.each { |k, v| hash[k] = _to_hash(v) }
250
+ end
251
+ elsif value.respond_to? :to_hash
252
+ value.to_hash
253
+ else
254
+ value
255
+ end
256
+ end
257
+ end
258
+ end