openapi_openai 1.0.0
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 +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +72 -0
- data/README.md +171 -0
- data/Rakefile +10 -0
- data/bin/bundle +109 -0
- data/bin/byebug +27 -0
- data/bin/coderay +27 -0
- data/bin/htmldiff +27 -0
- data/bin/ldiff +27 -0
- data/bin/pry +27 -0
- data/bin/racc +27 -0
- data/bin/rake +27 -0
- data/bin/rspec +27 -0
- data/bin/rubocop +27 -0
- data/bin/ruby-parse +27 -0
- data/bin/ruby-rewrite +27 -0
- data/docs/ChatCompletionFunctions.md +22 -0
- data/docs/ChatCompletionRequestMessage.md +24 -0
- data/docs/ChatCompletionRequestMessageFunctionCall.md +20 -0
- data/docs/ChatCompletionResponseMessage.md +22 -0
- data/docs/ChatCompletionStreamResponseDelta.md +22 -0
- data/docs/CreateChatCompletionRequest.md +44 -0
- data/docs/CreateChatCompletionRequestFunctionCall.md +49 -0
- data/docs/CreateChatCompletionRequestFunctionCallOneOf.md +18 -0
- data/docs/CreateChatCompletionRequestModel.md +47 -0
- data/docs/CreateChatCompletionRequestStop.md +49 -0
- data/docs/CreateChatCompletionResponse.md +28 -0
- data/docs/CreateChatCompletionResponseChoicesInner.md +22 -0
- data/docs/CreateChatCompletionStreamResponse.md +26 -0
- data/docs/CreateChatCompletionStreamResponseChoicesInner.md +22 -0
- data/docs/CreateCompletionRequest.md +48 -0
- data/docs/CreateCompletionRequestModel.md +47 -0
- data/docs/CreateCompletionRequestPrompt.md +53 -0
- data/docs/CreateCompletionRequestStop.md +49 -0
- data/docs/CreateCompletionResponse.md +28 -0
- data/docs/CreateCompletionResponseChoicesInner.md +24 -0
- data/docs/CreateCompletionResponseChoicesInnerLogprobs.md +24 -0
- data/docs/CreateCompletionResponseUsage.md +22 -0
- data/docs/CreateEditRequest.md +28 -0
- data/docs/CreateEditRequestModel.md +47 -0
- data/docs/CreateEditResponse.md +24 -0
- data/docs/CreateEditResponseChoicesInner.md +24 -0
- data/docs/CreateEmbeddingRequest.md +22 -0
- data/docs/CreateEmbeddingRequestInput.md +53 -0
- data/docs/CreateEmbeddingRequestModel.md +47 -0
- data/docs/CreateEmbeddingResponse.md +24 -0
- data/docs/CreateEmbeddingResponseDataInner.md +22 -0
- data/docs/CreateEmbeddingResponseUsage.md +20 -0
- data/docs/CreateFineTuneRequest.md +40 -0
- data/docs/CreateFineTuneRequestModel.md +47 -0
- data/docs/CreateImageRequest.md +26 -0
- data/docs/CreateModerationRequest.md +20 -0
- data/docs/CreateModerationRequestInput.md +49 -0
- data/docs/CreateModerationRequestModel.md +47 -0
- data/docs/CreateModerationResponse.md +22 -0
- data/docs/CreateModerationResponseResultsInner.md +22 -0
- data/docs/CreateModerationResponseResultsInnerCategories.md +30 -0
- data/docs/CreateModerationResponseResultsInnerCategoryScores.md +30 -0
- data/docs/CreateTranscriptionRequestModel.md +47 -0
- data/docs/CreateTranscriptionResponse.md +18 -0
- data/docs/CreateTranslationResponse.md +18 -0
- data/docs/DeleteFileResponse.md +22 -0
- data/docs/DeleteModelResponse.md +22 -0
- data/docs/Error.md +24 -0
- data/docs/ErrorResponse.md +18 -0
- data/docs/FineTune.md +42 -0
- data/docs/FineTuneEvent.md +24 -0
- data/docs/ImagesResponse.md +20 -0
- data/docs/ImagesResponseDataInner.md +20 -0
- data/docs/ListFilesResponse.md +20 -0
- data/docs/ListFineTuneEventsResponse.md +20 -0
- data/docs/ListFineTunesResponse.md +20 -0
- data/docs/ListModelsResponse.md +20 -0
- data/docs/Model.md +24 -0
- data/docs/OpenAIApi.md +1499 -0
- data/docs/OpenAIFile.md +32 -0
- data/git_push.sh +57 -0
- data/lib/openapi_openai/api/open_ai_api.rb +1583 -0
- data/lib/openapi_openai/api_client.rb +393 -0
- data/lib/openapi_openai/api_error.rb +58 -0
- data/lib/openapi_openai/configuration.rb +291 -0
- data/lib/openapi_openai/models/chat_completion_functions.rb +244 -0
- data/lib/openapi_openai/models/chat_completion_request_message.rb +285 -0
- data/lib/openapi_openai/models/chat_completion_request_message_function_call.rb +226 -0
- data/lib/openapi_openai/models/chat_completion_response_message.rb +276 -0
- data/lib/openapi_openai/models/chat_completion_stream_response_delta.rb +269 -0
- data/lib/openapi_openai/models/create_chat_completion_request.rb +537 -0
- data/lib/openapi_openai/models/create_chat_completion_request_function_call.rb +106 -0
- data/lib/openapi_openai/models/create_chat_completion_request_function_call_one_of.rb +222 -0
- data/lib/openapi_openai/models/create_chat_completion_request_model.rb +105 -0
- data/lib/openapi_openai/models/create_chat_completion_request_stop.rb +106 -0
- data/lib/openapi_openai/models/create_chat_completion_response.rb +296 -0
- data/lib/openapi_openai/models/create_chat_completion_response_choices_inner.rb +266 -0
- data/lib/openapi_openai/models/create_chat_completion_stream_response.rb +287 -0
- data/lib/openapi_openai/models/create_chat_completion_stream_response_choices_inner.rb +266 -0
- data/lib/openapi_openai/models/create_completion_request.rb +586 -0
- data/lib/openapi_openai/models/create_completion_request_model.rb +105 -0
- data/lib/openapi_openai/models/create_completion_request_prompt.rb +108 -0
- data/lib/openapi_openai/models/create_completion_request_stop.rb +106 -0
- data/lib/openapi_openai/models/create_completion_response.rb +296 -0
- data/lib/openapi_openai/models/create_completion_response_choices_inner.rb +299 -0
- data/lib/openapi_openai/models/create_completion_response_choices_inner_logprobs.rb +249 -0
- data/lib/openapi_openai/models/create_completion_response_usage.rb +253 -0
- data/lib/openapi_openai/models/create_edit_request.rb +362 -0
- data/lib/openapi_openai/models/create_edit_request_model.rb +105 -0
- data/lib/openapi_openai/models/create_edit_response.rb +271 -0
- data/lib/openapi_openai/models/create_edit_response_choices_inner.rb +276 -0
- data/lib/openapi_openai/models/create_embedding_request.rb +247 -0
- data/lib/openapi_openai/models/create_embedding_request_input.rb +108 -0
- data/lib/openapi_openai/models/create_embedding_request_model.rb +105 -0
- data/lib/openapi_openai/models/create_embedding_response.rb +271 -0
- data/lib/openapi_openai/models/create_embedding_response_data_inner.rb +255 -0
- data/lib/openapi_openai/models/create_embedding_response_usage.rb +237 -0
- data/lib/openapi_openai/models/create_fine_tune_request.rb +374 -0
- data/lib/openapi_openai/models/create_fine_tune_request_model.rb +105 -0
- data/lib/openapi_openai/models/create_image_request.rb +341 -0
- data/lib/openapi_openai/models/create_moderation_request.rb +230 -0
- data/lib/openapi_openai/models/create_moderation_request_input.rb +106 -0
- data/lib/openapi_openai/models/create_moderation_request_model.rb +105 -0
- data/lib/openapi_openai/models/create_moderation_response.rb +255 -0
- data/lib/openapi_openai/models/create_moderation_response_results_inner.rb +253 -0
- data/lib/openapi_openai/models/create_moderation_response_results_inner_categories.rb +317 -0
- data/lib/openapi_openai/models/create_moderation_response_results_inner_category_scores.rb +317 -0
- data/lib/openapi_openai/models/create_transcription_request_model.rb +105 -0
- data/lib/openapi_openai/models/create_transcription_response.rb +221 -0
- data/lib/openapi_openai/models/create_translation_response.rb +221 -0
- data/lib/openapi_openai/models/delete_file_response.rb +253 -0
- data/lib/openapi_openai/models/delete_model_response.rb +253 -0
- data/lib/openapi_openai/models/error.rb +261 -0
- data/lib/openapi_openai/models/error_response.rb +221 -0
- data/lib/openapi_openai/models/fine_tune.rb +410 -0
- data/lib/openapi_openai/models/fine_tune_event.rb +269 -0
- data/lib/openapi_openai/models/images_response.rb +239 -0
- data/lib/openapi_openai/models/images_response_data_inner.rb +223 -0
- data/lib/openapi_openai/models/list_files_response.rb +239 -0
- data/lib/openapi_openai/models/list_fine_tune_events_response.rb +239 -0
- data/lib/openapi_openai/models/list_fine_tunes_response.rb +239 -0
- data/lib/openapi_openai/models/list_models_response.rb +239 -0
- data/lib/openapi_openai/models/model.rb +269 -0
- data/lib/openapi_openai/models/open_ai_file.rb +320 -0
- data/lib/openapi_openai/version.rb +15 -0
- data/lib/openapi_openai.rb +99 -0
- data/openapi_openai.gemspec +39 -0
- data/spec/api/open_ai_api_spec.rb +306 -0
- data/spec/models/chat_completion_functions_spec.rb +48 -0
- data/spec/models/chat_completion_request_message_function_call_spec.rb +42 -0
- data/spec/models/chat_completion_request_message_spec.rb +58 -0
- data/spec/models/chat_completion_response_message_spec.rb +52 -0
- data/spec/models/chat_completion_stream_response_delta_spec.rb +52 -0
- data/spec/models/create_chat_completion_request_function_call_one_of_spec.rb +36 -0
- data/spec/models/create_chat_completion_request_function_call_spec.rb +32 -0
- data/spec/models/create_chat_completion_request_model_spec.rb +32 -0
- data/spec/models/create_chat_completion_request_spec.rb +114 -0
- data/spec/models/create_chat_completion_request_stop_spec.rb +32 -0
- data/spec/models/create_chat_completion_response_choices_inner_spec.rb +52 -0
- data/spec/models/create_chat_completion_response_spec.rb +66 -0
- data/spec/models/create_chat_completion_stream_response_choices_inner_spec.rb +52 -0
- data/spec/models/create_chat_completion_stream_response_spec.rb +60 -0
- data/spec/models/create_completion_request_model_spec.rb +32 -0
- data/spec/models/create_completion_request_prompt_spec.rb +32 -0
- data/spec/models/create_completion_request_spec.rb +126 -0
- data/spec/models/create_completion_request_stop_spec.rb +32 -0
- data/spec/models/create_completion_response_choices_inner_logprobs_spec.rb +54 -0
- data/spec/models/create_completion_response_choices_inner_spec.rb +58 -0
- data/spec/models/create_completion_response_spec.rb +66 -0
- data/spec/models/create_completion_response_usage_spec.rb +48 -0
- data/spec/models/create_edit_request_model_spec.rb +32 -0
- data/spec/models/create_edit_request_spec.rb +66 -0
- data/spec/models/create_edit_response_choices_inner_spec.rb +58 -0
- data/spec/models/create_edit_response_spec.rb +54 -0
- data/spec/models/create_embedding_request_input_spec.rb +32 -0
- data/spec/models/create_embedding_request_model_spec.rb +32 -0
- data/spec/models/create_embedding_request_spec.rb +48 -0
- data/spec/models/create_embedding_response_data_inner_spec.rb +48 -0
- data/spec/models/create_embedding_response_spec.rb +54 -0
- data/spec/models/create_embedding_response_usage_spec.rb +42 -0
- data/spec/models/create_fine_tune_request_model_spec.rb +32 -0
- data/spec/models/create_fine_tune_request_spec.rb +102 -0
- data/spec/models/create_image_request_spec.rb +68 -0
- data/spec/models/create_moderation_request_input_spec.rb +32 -0
- data/spec/models/create_moderation_request_model_spec.rb +32 -0
- data/spec/models/create_moderation_request_spec.rb +42 -0
- data/spec/models/create_moderation_response_results_inner_categories_spec.rb +72 -0
- data/spec/models/create_moderation_response_results_inner_category_scores_spec.rb +72 -0
- data/spec/models/create_moderation_response_results_inner_spec.rb +48 -0
- data/spec/models/create_moderation_response_spec.rb +48 -0
- data/spec/models/create_transcription_request_model_spec.rb +32 -0
- data/spec/models/create_transcription_response_spec.rb +36 -0
- data/spec/models/create_translation_response_spec.rb +36 -0
- data/spec/models/delete_file_response_spec.rb +48 -0
- data/spec/models/delete_model_response_spec.rb +48 -0
- data/spec/models/error_response_spec.rb +36 -0
- data/spec/models/error_spec.rb +54 -0
- data/spec/models/fine_tune_event_spec.rb +54 -0
- data/spec/models/fine_tune_spec.rb +108 -0
- data/spec/models/images_response_data_inner_spec.rb +42 -0
- data/spec/models/images_response_spec.rb +42 -0
- data/spec/models/list_files_response_spec.rb +42 -0
- data/spec/models/list_fine_tune_events_response_spec.rb +42 -0
- data/spec/models/list_fine_tunes_response_spec.rb +42 -0
- data/spec/models/list_models_response_spec.rb +42 -0
- data/spec/models/model_spec.rb +54 -0
- data/spec/models/open_ai_file_spec.rb +78 -0
- data/spec/spec_helper.rb +111 -0
- metadata +348 -0
|
@@ -0,0 +1,253 @@
|
|
|
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 CreateCompletionResponseUsage
|
|
18
|
+
attr_accessor :prompt_tokens
|
|
19
|
+
|
|
20
|
+
attr_accessor :completion_tokens
|
|
21
|
+
|
|
22
|
+
attr_accessor :total_tokens
|
|
23
|
+
|
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
25
|
+
def self.attribute_map
|
|
26
|
+
{
|
|
27
|
+
:'prompt_tokens' => :'prompt_tokens',
|
|
28
|
+
:'completion_tokens' => :'completion_tokens',
|
|
29
|
+
:'total_tokens' => :'total_tokens'
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Returns all the JSON keys this model knows about
|
|
34
|
+
def self.acceptable_attributes
|
|
35
|
+
attribute_map.values
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Attribute type mapping.
|
|
39
|
+
def self.openapi_types
|
|
40
|
+
{
|
|
41
|
+
:'prompt_tokens' => :'Integer',
|
|
42
|
+
:'completion_tokens' => :'Integer',
|
|
43
|
+
:'total_tokens' => :'Integer'
|
|
44
|
+
}
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# List of attributes with nullable: true
|
|
48
|
+
def self.openapi_nullable
|
|
49
|
+
Set.new([
|
|
50
|
+
])
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Initializes the object
|
|
54
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
55
|
+
def initialize(attributes = {})
|
|
56
|
+
if (!attributes.is_a?(Hash))
|
|
57
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenApiOpenAIClient::CreateCompletionResponseUsage` initialize method"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
61
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
62
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
63
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenApiOpenAIClient::CreateCompletionResponseUsage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
64
|
+
end
|
|
65
|
+
h[k.to_sym] = v
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if attributes.key?(:'prompt_tokens')
|
|
69
|
+
self.prompt_tokens = attributes[:'prompt_tokens']
|
|
70
|
+
else
|
|
71
|
+
self.prompt_tokens = nil
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
if attributes.key?(:'completion_tokens')
|
|
75
|
+
self.completion_tokens = attributes[:'completion_tokens']
|
|
76
|
+
else
|
|
77
|
+
self.completion_tokens = nil
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
if attributes.key?(:'total_tokens')
|
|
81
|
+
self.total_tokens = attributes[:'total_tokens']
|
|
82
|
+
else
|
|
83
|
+
self.total_tokens = nil
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
88
|
+
# @return Array for valid properties with the reasons
|
|
89
|
+
def list_invalid_properties
|
|
90
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
91
|
+
invalid_properties = Array.new
|
|
92
|
+
if @prompt_tokens.nil?
|
|
93
|
+
invalid_properties.push('invalid value for "prompt_tokens", prompt_tokens cannot be nil.')
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
if @completion_tokens.nil?
|
|
97
|
+
invalid_properties.push('invalid value for "completion_tokens", completion_tokens cannot be nil.')
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
if @total_tokens.nil?
|
|
101
|
+
invalid_properties.push('invalid value for "total_tokens", total_tokens cannot be nil.')
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
invalid_properties
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Check to see if the all the properties in the model are valid
|
|
108
|
+
# @return true if the model is valid
|
|
109
|
+
def valid?
|
|
110
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
111
|
+
return false if @prompt_tokens.nil?
|
|
112
|
+
return false if @completion_tokens.nil?
|
|
113
|
+
return false if @total_tokens.nil?
|
|
114
|
+
true
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Checks equality by comparing each attribute.
|
|
118
|
+
# @param [Object] Object to be compared
|
|
119
|
+
def ==(o)
|
|
120
|
+
return true if self.equal?(o)
|
|
121
|
+
self.class == o.class &&
|
|
122
|
+
prompt_tokens == o.prompt_tokens &&
|
|
123
|
+
completion_tokens == o.completion_tokens &&
|
|
124
|
+
total_tokens == o.total_tokens
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# @see the `==` method
|
|
128
|
+
# @param [Object] Object to be compared
|
|
129
|
+
def eql?(o)
|
|
130
|
+
self == o
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Calculates hash code according to all attributes.
|
|
134
|
+
# @return [Integer] Hash code
|
|
135
|
+
def hash
|
|
136
|
+
[prompt_tokens, completion_tokens, total_tokens].hash
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Builds the object from hash
|
|
140
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
141
|
+
# @return [Object] Returns the model itself
|
|
142
|
+
def self.build_from_hash(attributes)
|
|
143
|
+
return nil unless attributes.is_a?(Hash)
|
|
144
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
145
|
+
transformed_hash = {}
|
|
146
|
+
openapi_types.each_pair do |key, type|
|
|
147
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
148
|
+
transformed_hash["#{key}"] = nil
|
|
149
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
150
|
+
# check to ensure the input is an array given that the attribute
|
|
151
|
+
# is documented as an array but the input is not
|
|
152
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
153
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
154
|
+
end
|
|
155
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
156
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
new(transformed_hash)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Deserializes the data based on type
|
|
163
|
+
# @param string type Data type
|
|
164
|
+
# @param string value Value to be deserialized
|
|
165
|
+
# @return [Object] Deserialized data
|
|
166
|
+
def self._deserialize(type, value)
|
|
167
|
+
case type.to_sym
|
|
168
|
+
when :Time
|
|
169
|
+
Time.parse(value)
|
|
170
|
+
when :Date
|
|
171
|
+
Date.parse(value)
|
|
172
|
+
when :String
|
|
173
|
+
value.to_s
|
|
174
|
+
when :Integer
|
|
175
|
+
value.to_i
|
|
176
|
+
when :Float
|
|
177
|
+
value.to_f
|
|
178
|
+
when :Boolean
|
|
179
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
180
|
+
true
|
|
181
|
+
else
|
|
182
|
+
false
|
|
183
|
+
end
|
|
184
|
+
when :Object
|
|
185
|
+
# generic object (usually a Hash), return directly
|
|
186
|
+
value
|
|
187
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
188
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
189
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
190
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
191
|
+
k_type = Regexp.last_match[:k_type]
|
|
192
|
+
v_type = Regexp.last_match[:v_type]
|
|
193
|
+
{}.tap do |hash|
|
|
194
|
+
value.each do |k, v|
|
|
195
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
else # model
|
|
199
|
+
# models (e.g. Pet) or oneOf
|
|
200
|
+
klass = OpenApiOpenAIClient.const_get(type)
|
|
201
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Returns the string representation of the object
|
|
206
|
+
# @return [String] String presentation of the object
|
|
207
|
+
def to_s
|
|
208
|
+
to_hash.to_s
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
212
|
+
# @return [Hash] Returns the object in the form of hash
|
|
213
|
+
def to_body
|
|
214
|
+
to_hash
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# Returns the object in the form of hash
|
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
|
219
|
+
def to_hash
|
|
220
|
+
hash = {}
|
|
221
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
222
|
+
value = self.send(attr)
|
|
223
|
+
if value.nil?
|
|
224
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
225
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
hash[param] = _to_hash(value)
|
|
229
|
+
end
|
|
230
|
+
hash
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Outputs non-array value in the form of hash
|
|
234
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
235
|
+
# @param [Object] value Any valid value
|
|
236
|
+
# @return [Hash] Returns the value in the form of hash
|
|
237
|
+
def _to_hash(value)
|
|
238
|
+
if value.is_a?(Array)
|
|
239
|
+
value.compact.map { |v| _to_hash(v) }
|
|
240
|
+
elsif value.is_a?(Hash)
|
|
241
|
+
{}.tap do |hash|
|
|
242
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
243
|
+
end
|
|
244
|
+
elsif value.respond_to? :to_hash
|
|
245
|
+
value.to_hash
|
|
246
|
+
else
|
|
247
|
+
value
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
end
|
|
@@ -0,0 +1,362 @@
|
|
|
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 CreateEditRequest
|
|
18
|
+
attr_accessor :model
|
|
19
|
+
|
|
20
|
+
# The input text to use as a starting point for the edit.
|
|
21
|
+
attr_accessor :input
|
|
22
|
+
|
|
23
|
+
# The instruction that tells the model how to edit the prompt.
|
|
24
|
+
attr_accessor :instruction
|
|
25
|
+
|
|
26
|
+
# How many edits to generate for the input and instruction.
|
|
27
|
+
attr_accessor :n
|
|
28
|
+
|
|
29
|
+
# What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
|
|
30
|
+
attr_accessor :temperature
|
|
31
|
+
|
|
32
|
+
# An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.
|
|
33
|
+
attr_accessor :top_p
|
|
34
|
+
|
|
35
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
36
|
+
def self.attribute_map
|
|
37
|
+
{
|
|
38
|
+
:'model' => :'model',
|
|
39
|
+
:'input' => :'input',
|
|
40
|
+
:'instruction' => :'instruction',
|
|
41
|
+
:'n' => :'n',
|
|
42
|
+
:'temperature' => :'temperature',
|
|
43
|
+
:'top_p' => :'top_p'
|
|
44
|
+
}
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Returns all the JSON keys this model knows about
|
|
48
|
+
def self.acceptable_attributes
|
|
49
|
+
attribute_map.values
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Attribute type mapping.
|
|
53
|
+
def self.openapi_types
|
|
54
|
+
{
|
|
55
|
+
:'model' => :'CreateEditRequestModel',
|
|
56
|
+
:'input' => :'String',
|
|
57
|
+
:'instruction' => :'String',
|
|
58
|
+
:'n' => :'Integer',
|
|
59
|
+
:'temperature' => :'Float',
|
|
60
|
+
:'top_p' => :'Float'
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# List of attributes with nullable: true
|
|
65
|
+
def self.openapi_nullable
|
|
66
|
+
Set.new([
|
|
67
|
+
:'input',
|
|
68
|
+
:'n',
|
|
69
|
+
:'temperature',
|
|
70
|
+
:'top_p'
|
|
71
|
+
])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Initializes the object
|
|
75
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
76
|
+
def initialize(attributes = {})
|
|
77
|
+
if (!attributes.is_a?(Hash))
|
|
78
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenApiOpenAIClient::CreateEditRequest` initialize method"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
82
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
83
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
84
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenApiOpenAIClient::CreateEditRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
85
|
+
end
|
|
86
|
+
h[k.to_sym] = v
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if attributes.key?(:'model')
|
|
90
|
+
self.model = attributes[:'model']
|
|
91
|
+
else
|
|
92
|
+
self.model = nil
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
if attributes.key?(:'input')
|
|
96
|
+
self.input = attributes[:'input']
|
|
97
|
+
else
|
|
98
|
+
self.input = ''
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'instruction')
|
|
102
|
+
self.instruction = attributes[:'instruction']
|
|
103
|
+
else
|
|
104
|
+
self.instruction = nil
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
if attributes.key?(:'n')
|
|
108
|
+
self.n = attributes[:'n']
|
|
109
|
+
else
|
|
110
|
+
self.n = 1
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
if attributes.key?(:'temperature')
|
|
114
|
+
self.temperature = attributes[:'temperature']
|
|
115
|
+
else
|
|
116
|
+
self.temperature = 1
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
if attributes.key?(:'top_p')
|
|
120
|
+
self.top_p = attributes[:'top_p']
|
|
121
|
+
else
|
|
122
|
+
self.top_p = 1
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
127
|
+
# @return Array for valid properties with the reasons
|
|
128
|
+
def list_invalid_properties
|
|
129
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
130
|
+
invalid_properties = Array.new
|
|
131
|
+
if @model.nil?
|
|
132
|
+
invalid_properties.push('invalid value for "model", model cannot be nil.')
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
if @instruction.nil?
|
|
136
|
+
invalid_properties.push('invalid value for "instruction", instruction cannot be nil.')
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
if !@n.nil? && @n > 20
|
|
140
|
+
invalid_properties.push('invalid value for "n", must be smaller than or equal to 20.')
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
if !@n.nil? && @n < 1
|
|
144
|
+
invalid_properties.push('invalid value for "n", must be greater than or equal to 1.')
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
if !@temperature.nil? && @temperature > 2
|
|
148
|
+
invalid_properties.push('invalid value for "temperature", must be smaller than or equal to 2.')
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
if !@temperature.nil? && @temperature < 0
|
|
152
|
+
invalid_properties.push('invalid value for "temperature", must be greater than or equal to 0.')
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
if !@top_p.nil? && @top_p > 1
|
|
156
|
+
invalid_properties.push('invalid value for "top_p", must be smaller than or equal to 1.')
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
if !@top_p.nil? && @top_p < 0
|
|
160
|
+
invalid_properties.push('invalid value for "top_p", must be greater than or equal to 0.')
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
invalid_properties
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Check to see if the all the properties in the model are valid
|
|
167
|
+
# @return true if the model is valid
|
|
168
|
+
def valid?
|
|
169
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
170
|
+
return false if @model.nil?
|
|
171
|
+
return false if @instruction.nil?
|
|
172
|
+
return false if !@n.nil? && @n > 20
|
|
173
|
+
return false if !@n.nil? && @n < 1
|
|
174
|
+
return false if !@temperature.nil? && @temperature > 2
|
|
175
|
+
return false if !@temperature.nil? && @temperature < 0
|
|
176
|
+
return false if !@top_p.nil? && @top_p > 1
|
|
177
|
+
return false if !@top_p.nil? && @top_p < 0
|
|
178
|
+
true
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Custom attribute writer method with validation
|
|
182
|
+
# @param [Object] n Value to be assigned
|
|
183
|
+
def n=(n)
|
|
184
|
+
if !n.nil? && n > 20
|
|
185
|
+
fail ArgumentError, 'invalid value for "n", must be smaller than or equal to 20.'
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
if !n.nil? && n < 1
|
|
189
|
+
fail ArgumentError, 'invalid value for "n", must be greater than or equal to 1.'
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
@n = n
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Custom attribute writer method with validation
|
|
196
|
+
# @param [Object] temperature Value to be assigned
|
|
197
|
+
def temperature=(temperature)
|
|
198
|
+
if !temperature.nil? && temperature > 2
|
|
199
|
+
fail ArgumentError, 'invalid value for "temperature", must be smaller than or equal to 2.'
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
if !temperature.nil? && temperature < 0
|
|
203
|
+
fail ArgumentError, 'invalid value for "temperature", must be greater than or equal to 0.'
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
@temperature = temperature
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Custom attribute writer method with validation
|
|
210
|
+
# @param [Object] top_p Value to be assigned
|
|
211
|
+
def top_p=(top_p)
|
|
212
|
+
if !top_p.nil? && top_p > 1
|
|
213
|
+
fail ArgumentError, 'invalid value for "top_p", must be smaller than or equal to 1.'
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
if !top_p.nil? && top_p < 0
|
|
217
|
+
fail ArgumentError, 'invalid value for "top_p", must be greater than or equal to 0.'
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
@top_p = top_p
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Checks equality by comparing each attribute.
|
|
224
|
+
# @param [Object] Object to be compared
|
|
225
|
+
def ==(o)
|
|
226
|
+
return true if self.equal?(o)
|
|
227
|
+
self.class == o.class &&
|
|
228
|
+
model == o.model &&
|
|
229
|
+
input == o.input &&
|
|
230
|
+
instruction == o.instruction &&
|
|
231
|
+
n == o.n &&
|
|
232
|
+
temperature == o.temperature &&
|
|
233
|
+
top_p == o.top_p
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# @see the `==` method
|
|
237
|
+
# @param [Object] Object to be compared
|
|
238
|
+
def eql?(o)
|
|
239
|
+
self == o
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# Calculates hash code according to all attributes.
|
|
243
|
+
# @return [Integer] Hash code
|
|
244
|
+
def hash
|
|
245
|
+
[model, input, instruction, n, temperature, top_p].hash
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Builds the object from hash
|
|
249
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
250
|
+
# @return [Object] Returns the model itself
|
|
251
|
+
def self.build_from_hash(attributes)
|
|
252
|
+
return nil unless attributes.is_a?(Hash)
|
|
253
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
254
|
+
transformed_hash = {}
|
|
255
|
+
openapi_types.each_pair do |key, type|
|
|
256
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
257
|
+
transformed_hash["#{key}"] = nil
|
|
258
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
259
|
+
# check to ensure the input is an array given that the attribute
|
|
260
|
+
# is documented as an array but the input is not
|
|
261
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
262
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
263
|
+
end
|
|
264
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
265
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
new(transformed_hash)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# Deserializes the data based on type
|
|
272
|
+
# @param string type Data type
|
|
273
|
+
# @param string value Value to be deserialized
|
|
274
|
+
# @return [Object] Deserialized data
|
|
275
|
+
def self._deserialize(type, value)
|
|
276
|
+
case type.to_sym
|
|
277
|
+
when :Time
|
|
278
|
+
Time.parse(value)
|
|
279
|
+
when :Date
|
|
280
|
+
Date.parse(value)
|
|
281
|
+
when :String
|
|
282
|
+
value.to_s
|
|
283
|
+
when :Integer
|
|
284
|
+
value.to_i
|
|
285
|
+
when :Float
|
|
286
|
+
value.to_f
|
|
287
|
+
when :Boolean
|
|
288
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
289
|
+
true
|
|
290
|
+
else
|
|
291
|
+
false
|
|
292
|
+
end
|
|
293
|
+
when :Object
|
|
294
|
+
# generic object (usually a Hash), return directly
|
|
295
|
+
value
|
|
296
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
297
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
298
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
299
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
300
|
+
k_type = Regexp.last_match[:k_type]
|
|
301
|
+
v_type = Regexp.last_match[:v_type]
|
|
302
|
+
{}.tap do |hash|
|
|
303
|
+
value.each do |k, v|
|
|
304
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
else # model
|
|
308
|
+
# models (e.g. Pet) or oneOf
|
|
309
|
+
klass = OpenApiOpenAIClient.const_get(type)
|
|
310
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# Returns the string representation of the object
|
|
315
|
+
# @return [String] String presentation of the object
|
|
316
|
+
def to_s
|
|
317
|
+
to_hash.to_s
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
321
|
+
# @return [Hash] Returns the object in the form of hash
|
|
322
|
+
def to_body
|
|
323
|
+
to_hash
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
# Returns the object in the form of hash
|
|
327
|
+
# @return [Hash] Returns the object in the form of hash
|
|
328
|
+
def to_hash
|
|
329
|
+
hash = {}
|
|
330
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
331
|
+
value = self.send(attr)
|
|
332
|
+
if value.nil?
|
|
333
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
334
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
hash[param] = _to_hash(value)
|
|
338
|
+
end
|
|
339
|
+
hash
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
# Outputs non-array value in the form of hash
|
|
343
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
344
|
+
# @param [Object] value Any valid value
|
|
345
|
+
# @return [Hash] Returns the value in the form of hash
|
|
346
|
+
def _to_hash(value)
|
|
347
|
+
if value.is_a?(Array)
|
|
348
|
+
value.compact.map { |v| _to_hash(v) }
|
|
349
|
+
elsif value.is_a?(Hash)
|
|
350
|
+
{}.tap do |hash|
|
|
351
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
352
|
+
end
|
|
353
|
+
elsif value.respond_to? :to_hash
|
|
354
|
+
value.to_hash
|
|
355
|
+
else
|
|
356
|
+
value
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
end
|