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.
- checksums.yaml +4 -4
- data/Gemfile +10 -0
- data/Gemfile.lock +76 -0
- data/README.md +50 -87
- data/Rakefile +10 -0
- data/azure_openai_client.gemspec +38 -0
- data/docs/ChatCompletionsCreate200Response.md +28 -0
- data/docs/ChatCompletionsCreate200ResponseChoicesInner.md +22 -0
- data/docs/ChatCompletionsCreate200ResponseChoicesInnerMessage.md +20 -0
- data/docs/ChatCompletionsCreate200ResponseUsage.md +22 -0
- data/docs/ChatCompletionsCreateRequest.md +38 -0
- data/docs/ChatCompletionsCreateRequestMessagesInner.md +22 -0
- data/docs/ChatCompletionsCreateRequestStop.md +49 -0
- data/docs/CompletionsCreate200Response.md +28 -0
- data/docs/CompletionsCreate200ResponseChoicesInner.md +24 -0
- data/docs/CompletionsCreate200ResponseChoicesInnerLogprobs.md +24 -0
- data/docs/CompletionsCreate200ResponseUsage.md +22 -0
- data/docs/CompletionsCreateRequest.md +52 -0
- data/docs/CompletionsCreateRequestPrompt.md +49 -0
- data/docs/CompletionsCreateRequestStop.md +49 -0
- data/docs/DefaultApi.md +238 -0
- data/docs/EmbeddingsCreate200Response.md +24 -0
- data/docs/EmbeddingsCreate200ResponseDataInner.md +22 -0
- data/docs/EmbeddingsCreate200ResponseUsage.md +20 -0
- data/docs/EmbeddingsCreateRequest.md +24 -0
- data/docs/EmbeddingsCreateRequestInput.md +49 -0
- data/docs/ErrorResponse.md +18 -0
- data/docs/ErrorResponseError.md +24 -0
- data/git_push.sh +53 -0
- data/inference.json +816 -0
- data/lib/azure_openai_client/api/default_api.rb +120 -93
- data/lib/azure_openai_client/api_client.rb +77 -75
- data/lib/azure_openai_client/api_error.rb +5 -5
- data/lib/azure_openai_client/configuration.rb +114 -22
- data/lib/azure_openai_client/models/{inline_response_200_2.rb → chat_completions_create200_response.rb} +34 -26
- data/lib/azure_openai_client/models/{inline_response_200_2_choices.rb → chat_completions_create200_response_choices_inner.rb} +28 -20
- data/lib/azure_openai_client/models/{inline_response_200_2_message.rb → chat_completions_create200_response_choices_inner_message.rb} +28 -20
- data/lib/azure_openai_client/models/{inline_response_200_2_usage.rb → chat_completions_create200_response_usage.rb} +28 -20
- data/lib/azure_openai_client/models/{chat_completions_body.rb → chat_completions_create_request.rb} +183 -37
- data/lib/azure_openai_client/models/{deploymentsdeploymentidchatcompletions_messages.rb → chat_completions_create_request_messages_inner.rb} +30 -22
- data/lib/azure_openai_client/models/chat_completions_create_request_stop.rb +105 -0
- data/lib/azure_openai_client/models/{inline_response_200.rb → completions_create200_response.rb} +34 -26
- data/lib/azure_openai_client/models/{inline_response_200_choices.rb → completions_create200_response_choices_inner.rb} +30 -22
- data/lib/azure_openai_client/models/{inline_response_200_logprobs.rb → completions_create200_response_choices_inner_logprobs.rb} +30 -22
- data/lib/azure_openai_client/models/{inline_response_200_usage.rb → completions_create200_response_usage.rb} +28 -20
- data/lib/azure_openai_client/models/{deploymentid_completions_body.rb → completions_create_request.rb} +58 -52
- data/lib/azure_openai_client/models/completions_create_request_prompt.rb +105 -0
- data/lib/azure_openai_client/models/completions_create_request_stop.rb +105 -0
- data/lib/azure_openai_client/models/{inline_response_200_1.rb → embeddings_create200_response.rb} +30 -22
- data/lib/azure_openai_client/models/{inline_response_200_1_data.rb → embeddings_create200_response_data_inner.rb} +28 -20
- data/lib/azure_openai_client/models/{inline_response_200_1_usage.rb → embeddings_create200_response_usage.rb} +26 -18
- data/lib/azure_openai_client/models/embeddings_create_request.rb +252 -0
- data/lib/azure_openai_client/models/embeddings_create_request_input.rb +105 -0
- data/lib/azure_openai_client/models/error_response.rb +21 -13
- data/lib/azure_openai_client/models/error_response_error.rb +27 -19
- data/lib/azure_openai_client/version.rb +5 -6
- data/lib/azure_openai_client.rb +23 -23
- data/openapi-codegen.sh +12 -0
- data/openapi_config.yaml +15 -0
- data/spec/api/default_api_spec.rb +21 -22
- data/spec/api_client_spec.rb +15 -16
- data/spec/configuration_spec.rb +3 -3
- data/spec/models/chat_completions_create200_response_choices_inner_message_spec.rb +44 -0
- data/spec/models/chat_completions_create200_response_choices_inner_spec.rb +46 -0
- data/spec/models/chat_completions_create200_response_spec.rb +64 -0
- data/spec/models/chat_completions_create200_response_usage_spec.rb +46 -0
- data/spec/models/chat_completions_create_request_messages_inner_spec.rb +50 -0
- data/spec/models/chat_completions_create_request_spec.rb +94 -0
- data/spec/models/chat_completions_create_request_stop_spec.rb +31 -0
- data/spec/models/completions_create200_response_choices_inner_logprobs_spec.rb +52 -0
- data/spec/models/completions_create200_response_choices_inner_spec.rb +52 -0
- data/spec/models/completions_create200_response_spec.rb +64 -0
- data/spec/models/completions_create200_response_usage_spec.rb +46 -0
- data/spec/models/completions_create_request_prompt_spec.rb +31 -0
- data/spec/models/completions_create_request_spec.rb +136 -0
- data/spec/models/completions_create_request_stop_spec.rb +31 -0
- data/spec/models/embeddings_create200_response_data_inner_spec.rb +46 -0
- data/spec/models/embeddings_create200_response_spec.rb +52 -0
- data/spec/models/embeddings_create200_response_usage_spec.rb +40 -0
- data/spec/models/embeddings_create_request_input_spec.rb +31 -0
- data/spec/models/embeddings_create_request_spec.rb +52 -0
- data/spec/models/error_response_error_spec.rb +12 -20
- data/spec/models/error_response_spec.rb +9 -17
- data/spec/spec_helper.rb +4 -5
- metadata +91 -77
- data/lib/azure_openai_client/models/deploymentid_embeddings_body.rb +0 -202
- data/lib/azure_openai_client/models/one_ofchat_completions_body_stop.rb +0 -198
- data/lib/azure_openai_client/models/one_ofdeploymentid_completions_body_prompt.rb +0 -198
- data/lib/azure_openai_client/models/one_ofdeploymentid_completions_body_stop.rb +0 -198
- data/spec/models/chat_completions_body_spec.rb +0 -102
- data/spec/models/deploymentid_completions_body_spec.rb +0 -144
- data/spec/models/deploymentid_embeddings_body_spec.rb +0 -36
- data/spec/models/deploymentsdeploymentidchatcompletions_messages_spec.rb +0 -58
- data/spec/models/inline_response_200_1_data_spec.rb +0 -54
- data/spec/models/inline_response_200_1_spec.rb +0 -60
- data/spec/models/inline_response_200_1_usage_spec.rb +0 -48
- data/spec/models/inline_response_200_2_choices_spec.rb +0 -54
- data/spec/models/inline_response_200_2_message_spec.rb +0 -52
- data/spec/models/inline_response_200_2_spec.rb +0 -72
- data/spec/models/inline_response_200_2_usage_spec.rb +0 -54
- data/spec/models/inline_response_200_choices_spec.rb +0 -60
- data/spec/models/inline_response_200_logprobs_spec.rb +0 -60
- data/spec/models/inline_response_200_spec.rb +0 -72
- data/spec/models/inline_response_200_usage_spec.rb +0 -54
- data/spec/models/one_ofchat_completions_body_stop_spec.rb +0 -36
- data/spec/models/one_ofdeploymentid_completions_body_prompt_spec.rb +0 -36
- data/spec/models/one_ofdeploymentid_completions_body_stop_spec.rb +0 -36
@@ -0,0 +1,105 @@
|
|
1
|
+
=begin
|
2
|
+
#Azure OpenAI Service API
|
3
|
+
|
4
|
+
#Azure OpenAI APIs for completions and search
|
5
|
+
|
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
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module AzureOpenaiClient
|
17
|
+
# The prompt(s) to generate completions for, encoded as a string or array of strings. Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document. Maximum allowed size of string list is 2048.
|
18
|
+
module CompletionsCreateRequestPrompt
|
19
|
+
class << self
|
20
|
+
# List of class defined in oneOf (OpenAPI v3)
|
21
|
+
def openapi_one_of
|
22
|
+
[
|
23
|
+
:'Array<String>',
|
24
|
+
:'String'
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Builds the object
|
29
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
30
|
+
# @return [Object] Returns the model or the data itself
|
31
|
+
def build(data)
|
32
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
33
|
+
# Note:
|
34
|
+
# - We do not attempt to check whether exactly one item matches.
|
35
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
36
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
37
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
38
|
+
# - TODO: logging when debugging is set.
|
39
|
+
openapi_one_of.each do |klass|
|
40
|
+
begin
|
41
|
+
next if klass == :AnyType # "nullable: true"
|
42
|
+
typed_data = find_and_cast_into_type(klass, data)
|
43
|
+
return typed_data if typed_data
|
44
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
SchemaMismatchError = Class.new(StandardError)
|
54
|
+
|
55
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
56
|
+
def find_and_cast_into_type(klass, data)
|
57
|
+
return if data.nil?
|
58
|
+
|
59
|
+
case klass.to_s
|
60
|
+
when 'Boolean'
|
61
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
62
|
+
when 'Float'
|
63
|
+
return data if data.instance_of?(Float)
|
64
|
+
when 'Integer'
|
65
|
+
return data if data.instance_of?(Integer)
|
66
|
+
when 'Time'
|
67
|
+
return Time.parse(data)
|
68
|
+
when 'Date'
|
69
|
+
return Date.parse(data)
|
70
|
+
when 'String'
|
71
|
+
return data if data.instance_of?(String)
|
72
|
+
when 'Object' # "type: object"
|
73
|
+
return data if data.instance_of?(Hash)
|
74
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
75
|
+
if data.instance_of?(Array)
|
76
|
+
sub_type = Regexp.last_match[:sub_type]
|
77
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
78
|
+
end
|
79
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
80
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
81
|
+
sub_type = Regexp.last_match[:sub_type]
|
82
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
83
|
+
end
|
84
|
+
else # model
|
85
|
+
const = AzureOpenaiClient.const_get(klass)
|
86
|
+
if const
|
87
|
+
if const.respond_to?(:openapi_one_of) # nested oneOf model
|
88
|
+
model = const.build(data)
|
89
|
+
return model if model
|
90
|
+
else
|
91
|
+
# raise if data contains keys that are not known to the model
|
92
|
+
raise unless (data.keys - const.acceptable_attributes).empty?
|
93
|
+
model = const.build_from_hash(data)
|
94
|
+
return model if model && model.valid?
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
raise # if no match by now, raise
|
100
|
+
rescue
|
101
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
=begin
|
2
|
+
#Azure OpenAI Service API
|
3
|
+
|
4
|
+
#Azure OpenAI APIs for completions and search
|
5
|
+
|
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
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module AzureOpenaiClient
|
17
|
+
# Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
|
18
|
+
module CompletionsCreateRequestStop
|
19
|
+
class << self
|
20
|
+
# List of class defined in oneOf (OpenAPI v3)
|
21
|
+
def openapi_one_of
|
22
|
+
[
|
23
|
+
:'Array<String>',
|
24
|
+
:'String'
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Builds the object
|
29
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
30
|
+
# @return [Object] Returns the model or the data itself
|
31
|
+
def build(data)
|
32
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
33
|
+
# Note:
|
34
|
+
# - We do not attempt to check whether exactly one item matches.
|
35
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
36
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
37
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
38
|
+
# - TODO: logging when debugging is set.
|
39
|
+
openapi_one_of.each do |klass|
|
40
|
+
begin
|
41
|
+
next if klass == :AnyType # "nullable: true"
|
42
|
+
typed_data = find_and_cast_into_type(klass, data)
|
43
|
+
return typed_data if typed_data
|
44
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
SchemaMismatchError = Class.new(StandardError)
|
54
|
+
|
55
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
56
|
+
def find_and_cast_into_type(klass, data)
|
57
|
+
return if data.nil?
|
58
|
+
|
59
|
+
case klass.to_s
|
60
|
+
when 'Boolean'
|
61
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
62
|
+
when 'Float'
|
63
|
+
return data if data.instance_of?(Float)
|
64
|
+
when 'Integer'
|
65
|
+
return data if data.instance_of?(Integer)
|
66
|
+
when 'Time'
|
67
|
+
return Time.parse(data)
|
68
|
+
when 'Date'
|
69
|
+
return Date.parse(data)
|
70
|
+
when 'String'
|
71
|
+
return data if data.instance_of?(String)
|
72
|
+
when 'Object' # "type: object"
|
73
|
+
return data if data.instance_of?(Hash)
|
74
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
75
|
+
if data.instance_of?(Array)
|
76
|
+
sub_type = Regexp.last_match[:sub_type]
|
77
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
78
|
+
end
|
79
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
80
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
81
|
+
sub_type = Regexp.last_match[:sub_type]
|
82
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
83
|
+
end
|
84
|
+
else # model
|
85
|
+
const = AzureOpenaiClient.const_get(klass)
|
86
|
+
if const
|
87
|
+
if const.respond_to?(:openapi_one_of) # nested oneOf model
|
88
|
+
model = const.build(data)
|
89
|
+
return model if model
|
90
|
+
else
|
91
|
+
# raise if data contains keys that are not known to the model
|
92
|
+
raise unless (data.keys - const.acceptable_attributes).empty?
|
93
|
+
model = const.build_from_hash(data)
|
94
|
+
return model if model && model.valid?
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
raise # if no match by now, raise
|
100
|
+
rescue
|
101
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/azure_openai_client/models/{inline_response_200_1.rb → embeddings_create200_response.rb}
RENAMED
@@ -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
|
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
|
17
|
+
class EmbeddingsCreate200Response
|
18
18
|
attr_accessor :object
|
19
19
|
|
20
20
|
attr_accessor :model
|
@@ -26,20 +26,25 @@ module AzureOpenaiClient
|
|
26
26
|
# Attribute mapping from ruby-style variable name to JSON key.
|
27
27
|
def self.attribute_map
|
28
28
|
{
|
29
|
-
'object'
|
30
|
-
'model'
|
31
|
-
'data'
|
32
|
-
'usage'
|
29
|
+
:'object' => :'object',
|
30
|
+
:'model' => :'model',
|
31
|
+
:'data' => :'data',
|
32
|
+
:'usage' => :'usage'
|
33
33
|
}
|
34
34
|
end
|
35
35
|
|
36
|
+
# Returns all the JSON keys this model knows about
|
37
|
+
def self.acceptable_attributes
|
38
|
+
attribute_map.values
|
39
|
+
end
|
40
|
+
|
36
41
|
# Attribute type mapping.
|
37
42
|
def self.openapi_types
|
38
43
|
{
|
39
|
-
'object'
|
40
|
-
'model'
|
41
|
-
'data'
|
42
|
-
'usage'
|
44
|
+
:'object' => :'String',
|
45
|
+
:'model' => :'String',
|
46
|
+
:'data' => :'Array<EmbeddingsCreate200ResponseDataInner>',
|
47
|
+
:'usage' => :'EmbeddingsCreate200ResponseUsage'
|
43
48
|
}
|
44
49
|
end
|
45
50
|
|
@@ -53,13 +58,13 @@ module AzureOpenaiClient
|
|
53
58
|
# @param [Hash] attributes Model attributes in the form of hash
|
54
59
|
def initialize(attributes = {})
|
55
60
|
if (!attributes.is_a?(Hash))
|
56
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::
|
61
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::EmbeddingsCreate200Response` initialize method"
|
57
62
|
end
|
58
63
|
|
59
64
|
# check to see if the attribute exists and convert string to symbol for hash key
|
60
65
|
attributes = attributes.each_with_object({}) { |(k, v), h|
|
61
66
|
if (!self.class.attribute_map.key?(k.to_sym))
|
62
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::
|
67
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::EmbeddingsCreate200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
63
68
|
end
|
64
69
|
h[k.to_sym] = v
|
65
70
|
}
|
@@ -151,8 +156,11 @@ module AzureOpenaiClient
|
|
151
156
|
# @return [Object] Returns the model itself
|
152
157
|
def build_from_hash(attributes)
|
153
158
|
return nil unless attributes.is_a?(Hash)
|
159
|
+
attributes = attributes.transform_keys(&:to_sym)
|
154
160
|
self.class.openapi_types.each_pair do |key, type|
|
155
|
-
if
|
161
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
162
|
+
self.send("#{key}=", nil)
|
163
|
+
elsif type =~ /\AArray<(.*)>/i
|
156
164
|
# check to ensure the input is an array given that the attribute
|
157
165
|
# is documented as an array but the input is not
|
158
166
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -160,8 +168,6 @@ module AzureOpenaiClient
|
|
160
168
|
end
|
161
169
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
162
170
|
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
171
|
end
|
166
172
|
end
|
167
173
|
|
@@ -174,8 +180,8 @@ module AzureOpenaiClient
|
|
174
180
|
# @return [Object] Deserialized data
|
175
181
|
def _deserialize(type, value)
|
176
182
|
case type.to_sym
|
177
|
-
when :
|
178
|
-
|
183
|
+
when :Time
|
184
|
+
Time.parse(value)
|
179
185
|
when :Date
|
180
186
|
Date.parse(value)
|
181
187
|
when :String
|
@@ -205,7 +211,9 @@ module AzureOpenaiClient
|
|
205
211
|
end
|
206
212
|
end
|
207
213
|
else # model
|
208
|
-
|
214
|
+
# models (e.g. Pet) or oneOf
|
215
|
+
klass = AzureOpenaiClient.const_get(type)
|
216
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
209
217
|
end
|
210
218
|
end
|
211
219
|
|
@@ -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
|
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
|
17
|
+
class EmbeddingsCreate200ResponseDataInner
|
18
18
|
attr_accessor :index
|
19
19
|
|
20
20
|
attr_accessor :object
|
@@ -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'
|
28
|
-
'object'
|
29
|
-
'embedding'
|
27
|
+
:'index' => :'index',
|
28
|
+
:'object' => :'object',
|
29
|
+
:'embedding' => :'embedding'
|
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'
|
37
|
-
'object'
|
38
|
-
'embedding'
|
41
|
+
:'index' => :'Integer',
|
42
|
+
:'object' => :'String',
|
43
|
+
:'embedding' => :'Array<Float>'
|
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::
|
57
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::EmbeddingsCreate200ResponseDataInner` 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::
|
63
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::EmbeddingsCreate200ResponseDataInner`. 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
|
}
|
@@ -137,8 +142,11 @@ module AzureOpenaiClient
|
|
137
142
|
# @return [Object] Returns the model itself
|
138
143
|
def build_from_hash(attributes)
|
139
144
|
return nil unless attributes.is_a?(Hash)
|
145
|
+
attributes = attributes.transform_keys(&:to_sym)
|
140
146
|
self.class.openapi_types.each_pair do |key, type|
|
141
|
-
if
|
147
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
148
|
+
self.send("#{key}=", nil)
|
149
|
+
elsif type =~ /\AArray<(.*)>/i
|
142
150
|
# check to ensure the input is an array given that the attribute
|
143
151
|
# is documented as an array but the input is not
|
144
152
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -146,8 +154,6 @@ module AzureOpenaiClient
|
|
146
154
|
end
|
147
155
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
148
156
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
149
|
-
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
150
|
-
self.send("#{key}=", nil)
|
151
157
|
end
|
152
158
|
end
|
153
159
|
|
@@ -160,8 +166,8 @@ module AzureOpenaiClient
|
|
160
166
|
# @return [Object] Deserialized data
|
161
167
|
def _deserialize(type, value)
|
162
168
|
case type.to_sym
|
163
|
-
when :
|
164
|
-
|
169
|
+
when :Time
|
170
|
+
Time.parse(value)
|
165
171
|
when :Date
|
166
172
|
Date.parse(value)
|
167
173
|
when :String
|
@@ -191,7 +197,9 @@ module AzureOpenaiClient
|
|
191
197
|
end
|
192
198
|
end
|
193
199
|
else # model
|
194
|
-
|
200
|
+
# models (e.g. Pet) or oneOf
|
201
|
+
klass = AzureOpenaiClient.const_get(type)
|
202
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
195
203
|
end
|
196
204
|
end
|
197
205
|
|
@@ -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
|
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
|
17
|
+
class EmbeddingsCreate200ResponseUsage
|
18
18
|
attr_accessor :prompt_tokens
|
19
19
|
|
20
20
|
attr_accessor :total_tokens
|
@@ -22,16 +22,21 @@ module AzureOpenaiClient
|
|
22
22
|
# Attribute mapping from ruby-style variable name to JSON key.
|
23
23
|
def self.attribute_map
|
24
24
|
{
|
25
|
-
'prompt_tokens'
|
26
|
-
'total_tokens'
|
25
|
+
:'prompt_tokens' => :'prompt_tokens',
|
26
|
+
:'total_tokens' => :'total_tokens'
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
30
35
|
# Attribute type mapping.
|
31
36
|
def self.openapi_types
|
32
37
|
{
|
33
|
-
'prompt_tokens'
|
34
|
-
'total_tokens'
|
38
|
+
:'prompt_tokens' => :'Integer',
|
39
|
+
:'total_tokens' => :'Integer'
|
35
40
|
}
|
36
41
|
end
|
37
42
|
|
@@ -45,13 +50,13 @@ module AzureOpenaiClient
|
|
45
50
|
# @param [Hash] attributes Model attributes in the form of hash
|
46
51
|
def initialize(attributes = {})
|
47
52
|
if (!attributes.is_a?(Hash))
|
48
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `AzureOpenaiClient::EmbeddingsCreate200ResponseUsage` initialize method"
|
49
54
|
end
|
50
55
|
|
51
56
|
# check to see if the attribute exists and convert string to symbol for hash key
|
52
57
|
attributes = attributes.each_with_object({}) { |(k, v), h|
|
53
58
|
if (!self.class.attribute_map.key?(k.to_sym))
|
54
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `AzureOpenaiClient::EmbeddingsCreate200ResponseUsage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
55
60
|
end
|
56
61
|
h[k.to_sym] = v
|
57
62
|
}
|
@@ -121,8 +126,11 @@ module AzureOpenaiClient
|
|
121
126
|
# @return [Object] Returns the model itself
|
122
127
|
def build_from_hash(attributes)
|
123
128
|
return nil unless attributes.is_a?(Hash)
|
129
|
+
attributes = attributes.transform_keys(&:to_sym)
|
124
130
|
self.class.openapi_types.each_pair do |key, type|
|
125
|
-
if
|
131
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
132
|
+
self.send("#{key}=", nil)
|
133
|
+
elsif type =~ /\AArray<(.*)>/i
|
126
134
|
# check to ensure the input is an array given that the attribute
|
127
135
|
# is documented as an array but the input is not
|
128
136
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
@@ -130,8 +138,6 @@ module AzureOpenaiClient
|
|
130
138
|
end
|
131
139
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
132
140
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
133
|
-
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
134
|
-
self.send("#{key}=", nil)
|
135
141
|
end
|
136
142
|
end
|
137
143
|
|
@@ -144,8 +150,8 @@ module AzureOpenaiClient
|
|
144
150
|
# @return [Object] Deserialized data
|
145
151
|
def _deserialize(type, value)
|
146
152
|
case type.to_sym
|
147
|
-
when :
|
148
|
-
|
153
|
+
when :Time
|
154
|
+
Time.parse(value)
|
149
155
|
when :Date
|
150
156
|
Date.parse(value)
|
151
157
|
when :String
|
@@ -175,7 +181,9 @@ module AzureOpenaiClient
|
|
175
181
|
end
|
176
182
|
end
|
177
183
|
else # model
|
178
|
-
|
184
|
+
# models (e.g. Pet) or oneOf
|
185
|
+
klass = AzureOpenaiClient.const_get(type)
|
186
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
179
187
|
end
|
180
188
|
end
|
181
189
|
|