cuadra-ai-sdk 1.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.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +99 -0
- data/lib/cuadra_ai/api_helper.rb +10 -0
- data/lib/cuadra_ai/client.rb +91 -0
- data/lib/cuadra_ai/configuration.rb +105 -0
- data/lib/cuadra_ai/controllers/base_controller.rb +67 -0
- data/lib/cuadra_ai/controllers/chat_controller.rb +41 -0
- data/lib/cuadra_ai/controllers/embeds_controller.rb +41 -0
- data/lib/cuadra_ai/controllers/models_controller.rb +172 -0
- data/lib/cuadra_ai/controllers/oauth_authorization_controller.rb +87 -0
- data/lib/cuadra_ai/controllers/usage_controller.rb +70 -0
- data/lib/cuadra_ai/exceptions/api_exception.rb +21 -0
- data/lib/cuadra_ai/exceptions/error_response_exception.rb +57 -0
- data/lib/cuadra_ai/exceptions/oauth_provider_exception.rb +64 -0
- data/lib/cuadra_ai/http/api_response.rb +19 -0
- data/lib/cuadra_ai/http/auth/oauth_2.rb +139 -0
- data/lib/cuadra_ai/http/http_call_back.rb +10 -0
- data/lib/cuadra_ai/http/http_method_enum.rb +10 -0
- data/lib/cuadra_ai/http/http_request.rb +10 -0
- data/lib/cuadra_ai/http/http_response.rb +10 -0
- data/lib/cuadra_ai/logging/configuration/api_logging_configuration.rb +114 -0
- data/lib/cuadra_ai/logging/sdk_logger.rb +17 -0
- data/lib/cuadra_ai/models/base_model.rb +110 -0
- data/lib/cuadra_ai/models/chat.rb +102 -0
- data/lib/cuadra_ai/models/chat_response_ex.rb +106 -0
- data/lib/cuadra_ai/models/content_ex.rb +86 -0
- data/lib/cuadra_ai/models/embed.rb +100 -0
- data/lib/cuadra_ai/models/embed_response_ex.rb +85 -0
- data/lib/cuadra_ai/models/inline_data_ex.rb +87 -0
- data/lib/cuadra_ai/models/model_ex.rb +169 -0
- data/lib/cuadra_ai/models/oauth_provider_error.rb +45 -0
- data/lib/cuadra_ai/models/oauth_token.rb +96 -0
- data/lib/cuadra_ai/models/paginated_response_ex_list_model_ex.rb +104 -0
- data/lib/cuadra_ai/models/tokens_ex.rb +86 -0
- data/lib/cuadra_ai/models/total_usage_ex.rb +86 -0
- data/lib/cuadra_ai/models/usage_calculation_ex.rb +77 -0
- data/lib/cuadra_ai/models/usage_ex.rb +86 -0
- data/lib/cuadra_ai/utilities/date_time_helper.rb +11 -0
- data/lib/cuadra_ai/utilities/file_wrapper.rb +28 -0
- data/lib/cuadra_ai.rb +63 -0
- metadata +126 -0
@@ -0,0 +1,169 @@
|
|
1
|
+
# cuadra_ai
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
module CuadraAi
|
8
|
+
# ModelEx Model.
|
9
|
+
class ModelEx < BaseModel
|
10
|
+
SKIP = Object.new
|
11
|
+
private_constant :SKIP
|
12
|
+
|
13
|
+
# Model Id
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :id
|
16
|
+
|
17
|
+
# Model name
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
# Model type of content generation and processing
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :type
|
24
|
+
|
25
|
+
# Brief description of the model
|
26
|
+
# @return [String]
|
27
|
+
attr_accessor :description
|
28
|
+
|
29
|
+
# Indicates whether is a custom model created by you or not
|
30
|
+
# @return [TrueClass | FalseClass]
|
31
|
+
attr_accessor :proprietary
|
32
|
+
|
33
|
+
# Base model name, if it was created from another model
|
34
|
+
# @return [String]
|
35
|
+
attr_accessor :base_model
|
36
|
+
|
37
|
+
# Base model id, if it was created from another model
|
38
|
+
# @return [String]
|
39
|
+
attr_accessor :base_model_id
|
40
|
+
|
41
|
+
# Creation date
|
42
|
+
# @return [DateTime]
|
43
|
+
attr_accessor :created_at
|
44
|
+
|
45
|
+
# Last time it was updated
|
46
|
+
# @return [DateTime]
|
47
|
+
attr_accessor :updated_at
|
48
|
+
|
49
|
+
# A mapping from model property names to API property names.
|
50
|
+
def self.names
|
51
|
+
@_hash = {} if @_hash.nil?
|
52
|
+
@_hash['id'] = 'id'
|
53
|
+
@_hash['name'] = 'name'
|
54
|
+
@_hash['type'] = 'type'
|
55
|
+
@_hash['description'] = 'description'
|
56
|
+
@_hash['proprietary'] = 'proprietary'
|
57
|
+
@_hash['base_model'] = 'baseModel'
|
58
|
+
@_hash['base_model_id'] = 'baseModelId'
|
59
|
+
@_hash['created_at'] = 'createdAt'
|
60
|
+
@_hash['updated_at'] = 'updatedAt'
|
61
|
+
@_hash
|
62
|
+
end
|
63
|
+
|
64
|
+
# An array for optional fields
|
65
|
+
def self.optionals
|
66
|
+
%w[
|
67
|
+
id
|
68
|
+
proprietary
|
69
|
+
base_model
|
70
|
+
base_model_id
|
71
|
+
created_at
|
72
|
+
updated_at
|
73
|
+
]
|
74
|
+
end
|
75
|
+
|
76
|
+
# An array for nullable fields
|
77
|
+
def self.nullables
|
78
|
+
[]
|
79
|
+
end
|
80
|
+
|
81
|
+
def initialize(name:, type:, description:, id: SKIP, proprietary: SKIP,
|
82
|
+
base_model: SKIP, base_model_id: SKIP, created_at: SKIP,
|
83
|
+
updated_at: SKIP, additional_properties: nil)
|
84
|
+
# Add additional model properties to the instance
|
85
|
+
additional_properties = {} if additional_properties.nil?
|
86
|
+
|
87
|
+
@id = id unless id == SKIP
|
88
|
+
@name = name
|
89
|
+
@type = type
|
90
|
+
@description = description
|
91
|
+
@proprietary = proprietary unless proprietary == SKIP
|
92
|
+
@base_model = base_model unless base_model == SKIP
|
93
|
+
@base_model_id = base_model_id unless base_model_id == SKIP
|
94
|
+
@created_at = created_at unless created_at == SKIP
|
95
|
+
@updated_at = updated_at unless updated_at == SKIP
|
96
|
+
@additional_properties = additional_properties
|
97
|
+
end
|
98
|
+
|
99
|
+
# Creates an instance of the object from a hash.
|
100
|
+
def self.from_hash(hash)
|
101
|
+
return nil unless hash
|
102
|
+
|
103
|
+
# Extract variables from the hash.
|
104
|
+
name = hash.key?('name') ? hash['name'] : nil
|
105
|
+
type = hash.key?('type') ? hash['type'] : nil
|
106
|
+
description = hash.key?('description') ? hash['description'] : nil
|
107
|
+
id = hash.key?('id') ? hash['id'] : SKIP
|
108
|
+
proprietary = hash.key?('proprietary') ? hash['proprietary'] : SKIP
|
109
|
+
base_model = hash.key?('baseModel') ? hash['baseModel'] : SKIP
|
110
|
+
base_model_id = hash.key?('baseModelId') ? hash['baseModelId'] : SKIP
|
111
|
+
created_at = if hash.key?('createdAt')
|
112
|
+
(DateTimeHelper.from_rfc3339(hash['createdAt']) if hash['createdAt'])
|
113
|
+
else
|
114
|
+
SKIP
|
115
|
+
end
|
116
|
+
updated_at = if hash.key?('updatedAt')
|
117
|
+
(DateTimeHelper.from_rfc3339(hash['updatedAt']) if hash['updatedAt'])
|
118
|
+
else
|
119
|
+
SKIP
|
120
|
+
end
|
121
|
+
|
122
|
+
# Create a new hash for additional properties, removing known properties.
|
123
|
+
new_hash = hash.reject { |k, _| names.value?(k) }
|
124
|
+
|
125
|
+
additional_properties = APIHelper.get_additional_properties(
|
126
|
+
new_hash, proc { |value| value }
|
127
|
+
)
|
128
|
+
|
129
|
+
# Create object from extracted values.
|
130
|
+
ModelEx.new(name: name,
|
131
|
+
type: type,
|
132
|
+
description: description,
|
133
|
+
id: id,
|
134
|
+
proprietary: proprietary,
|
135
|
+
base_model: base_model,
|
136
|
+
base_model_id: base_model_id,
|
137
|
+
created_at: created_at,
|
138
|
+
updated_at: updated_at,
|
139
|
+
additional_properties: additional_properties)
|
140
|
+
end
|
141
|
+
|
142
|
+
def to_custom_created_at
|
143
|
+
DateTimeHelper.to_rfc3339(created_at)
|
144
|
+
end
|
145
|
+
|
146
|
+
def to_custom_updated_at
|
147
|
+
DateTimeHelper.to_rfc3339(updated_at)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Provides a human-readable string representation of the object.
|
151
|
+
def to_s
|
152
|
+
class_name = self.class.name.split('::').last
|
153
|
+
"<#{class_name} id: #{@id}, name: #{@name}, type: #{@type}, description: #{@description},"\
|
154
|
+
" proprietary: #{@proprietary}, base_model: #{@base_model}, base_model_id:"\
|
155
|
+
" #{@base_model_id}, created_at: #{@created_at}, updated_at: #{@updated_at},"\
|
156
|
+
" additional_properties: #{@additional_properties}>"
|
157
|
+
end
|
158
|
+
|
159
|
+
# Provides a debugging-friendly string with detailed object information.
|
160
|
+
def inspect
|
161
|
+
class_name = self.class.name.split('::').last
|
162
|
+
"<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, type: #{@type.inspect},"\
|
163
|
+
" description: #{@description.inspect}, proprietary: #{@proprietary.inspect}, base_model:"\
|
164
|
+
" #{@base_model.inspect}, base_model_id: #{@base_model_id.inspect}, created_at:"\
|
165
|
+
" #{@created_at.inspect}, updated_at: #{@updated_at.inspect}, additional_properties:"\
|
166
|
+
" #{@additional_properties}>"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# cuadra_ai
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module CuadraAi
|
7
|
+
# OAuth 2 Authorization error codes
|
8
|
+
class OauthProviderError
|
9
|
+
OAUTH_PROVIDER_ERROR = [
|
10
|
+
# The request is missing a required parameter, includes an unsupported
|
11
|
+
# parameter value (other than grant type), repeats a parameter, includes
|
12
|
+
# multiple credentials, utilizes more than one mechanism for
|
13
|
+
# authenticating the client, or is otherwise malformed.
|
14
|
+
INVALID_REQUEST = 'invalid_request'.freeze,
|
15
|
+
|
16
|
+
# Client authentication failed (e.g., unknown client, no client
|
17
|
+
# authentication included, or unsupported authentication method).
|
18
|
+
INVALID_CLIENT = 'invalid_client'.freeze,
|
19
|
+
|
20
|
+
# The provided authorization grant (e.g., authorization code, resource
|
21
|
+
# owner credentials) or refresh token is invalid, expired, revoked, does
|
22
|
+
# not match the redirection URI used in the authorization request, or was
|
23
|
+
# issued to another client.
|
24
|
+
INVALID_GRANT = 'invalid_grant'.freeze,
|
25
|
+
|
26
|
+
# The authenticated client is not authorized to use this authorization
|
27
|
+
# grant type.
|
28
|
+
UNAUTHORIZED_CLIENT = 'unauthorized_client'.freeze,
|
29
|
+
|
30
|
+
# The authorization grant type is not supported by the authorization
|
31
|
+
# server.
|
32
|
+
UNSUPPORTED_GRANT_TYPE = 'unsupported_grant_type'.freeze,
|
33
|
+
|
34
|
+
# The requested scope is invalid, unknown, malformed, or exceeds the scope
|
35
|
+
# granted by the resource owner.
|
36
|
+
INVALID_SCOPE = 'invalid_scope'.freeze
|
37
|
+
].freeze
|
38
|
+
|
39
|
+
def self.validate(value)
|
40
|
+
return false if value.nil?
|
41
|
+
|
42
|
+
OAUTH_PROVIDER_ERROR.include?(value)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# cuadra_ai
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module CuadraAi
|
7
|
+
# OAuth 2 Authorization endpoint response
|
8
|
+
class OauthToken < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# Access token
|
13
|
+
# @return [String]
|
14
|
+
attr_accessor :access_token
|
15
|
+
|
16
|
+
# Type of access token
|
17
|
+
# @return [String]
|
18
|
+
attr_accessor :token_type
|
19
|
+
|
20
|
+
# Time in seconds before the access token expires
|
21
|
+
# @return [Integer]
|
22
|
+
attr_accessor :expires_in
|
23
|
+
|
24
|
+
# List of scopes granted
|
25
|
+
# This is a space-delimited list of strings.
|
26
|
+
# @return [String]
|
27
|
+
attr_accessor :scope
|
28
|
+
|
29
|
+
# Time of token expiry as unix timestamp (UTC)
|
30
|
+
# @return [Integer]
|
31
|
+
attr_accessor :expiry
|
32
|
+
|
33
|
+
# Refresh token
|
34
|
+
# Used to get a new access token when it expires.
|
35
|
+
# @return [String]
|
36
|
+
attr_accessor :refresh_token
|
37
|
+
|
38
|
+
# A mapping from model property names to API property names.
|
39
|
+
def self.names
|
40
|
+
@_hash = {} if @_hash.nil?
|
41
|
+
@_hash['access_token'] = 'access_token'
|
42
|
+
@_hash['token_type'] = 'token_type'
|
43
|
+
@_hash['expires_in'] = 'expires_in'
|
44
|
+
@_hash['scope'] = 'scope'
|
45
|
+
@_hash['expiry'] = 'expiry'
|
46
|
+
@_hash['refresh_token'] = 'refresh_token'
|
47
|
+
@_hash
|
48
|
+
end
|
49
|
+
|
50
|
+
# An array for optional fields
|
51
|
+
def self.optionals
|
52
|
+
%w[
|
53
|
+
expires_in
|
54
|
+
scope
|
55
|
+
expiry
|
56
|
+
refresh_token
|
57
|
+
]
|
58
|
+
end
|
59
|
+
|
60
|
+
# An array for nullable fields
|
61
|
+
def self.nullables
|
62
|
+
[]
|
63
|
+
end
|
64
|
+
|
65
|
+
def initialize(access_token:, token_type:, expires_in: SKIP, scope: SKIP,
|
66
|
+
expiry: SKIP, refresh_token: SKIP)
|
67
|
+
@access_token = access_token
|
68
|
+
@token_type = token_type
|
69
|
+
@expires_in = expires_in unless expires_in == SKIP
|
70
|
+
@scope = scope unless scope == SKIP
|
71
|
+
@expiry = expiry unless expiry == SKIP
|
72
|
+
@refresh_token = refresh_token unless refresh_token == SKIP
|
73
|
+
end
|
74
|
+
|
75
|
+
# Creates an instance of the object from a hash.
|
76
|
+
def self.from_hash(hash)
|
77
|
+
return nil unless hash
|
78
|
+
|
79
|
+
# Extract variables from the hash.
|
80
|
+
access_token = hash.key?('access_token') ? hash['access_token'] : nil
|
81
|
+
token_type = hash.key?('token_type') ? hash['token_type'] : nil
|
82
|
+
expires_in = hash.key?('expires_in') ? hash['expires_in'] : SKIP
|
83
|
+
scope = hash.key?('scope') ? hash['scope'] : SKIP
|
84
|
+
expiry = hash.key?('expiry') ? hash['expiry'] : SKIP
|
85
|
+
refresh_token = hash.key?('refresh_token') ? hash['refresh_token'] : SKIP
|
86
|
+
|
87
|
+
# Create object from extracted values.
|
88
|
+
OauthToken.new(access_token: access_token,
|
89
|
+
token_type: token_type,
|
90
|
+
expires_in: expires_in,
|
91
|
+
scope: scope,
|
92
|
+
expiry: expiry,
|
93
|
+
refresh_token: refresh_token)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# cuadra_ai
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module CuadraAi
|
7
|
+
# PaginatedResponseExListModelEx Model.
|
8
|
+
class PaginatedResponseExListModelEx < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# TODO: Write general description for this method
|
13
|
+
# @return [Integer]
|
14
|
+
attr_accessor :page
|
15
|
+
|
16
|
+
# TODO: Write general description for this method
|
17
|
+
# @return [Integer]
|
18
|
+
attr_accessor :size
|
19
|
+
|
20
|
+
# TODO: Write general description for this method
|
21
|
+
# @return [Array[ModelEx]]
|
22
|
+
attr_accessor :data
|
23
|
+
|
24
|
+
# A mapping from model property names to API property names.
|
25
|
+
def self.names
|
26
|
+
@_hash = {} if @_hash.nil?
|
27
|
+
@_hash['page'] = 'page'
|
28
|
+
@_hash['size'] = 'size'
|
29
|
+
@_hash['data'] = 'data'
|
30
|
+
@_hash
|
31
|
+
end
|
32
|
+
|
33
|
+
# An array for optional fields
|
34
|
+
def self.optionals
|
35
|
+
%w[
|
36
|
+
page
|
37
|
+
size
|
38
|
+
data
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
# An array for nullable fields
|
43
|
+
def self.nullables
|
44
|
+
[]
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize(page: SKIP, size: SKIP, data: SKIP,
|
48
|
+
additional_properties: nil)
|
49
|
+
# Add additional model properties to the instance
|
50
|
+
additional_properties = {} if additional_properties.nil?
|
51
|
+
|
52
|
+
@page = page unless page == SKIP
|
53
|
+
@size = size unless size == SKIP
|
54
|
+
@data = data unless data == SKIP
|
55
|
+
@additional_properties = additional_properties
|
56
|
+
end
|
57
|
+
|
58
|
+
# Creates an instance of the object from a hash.
|
59
|
+
def self.from_hash(hash)
|
60
|
+
return nil unless hash
|
61
|
+
|
62
|
+
# Extract variables from the hash.
|
63
|
+
page = hash.key?('page') ? hash['page'] : SKIP
|
64
|
+
size = hash.key?('size') ? hash['size'] : SKIP
|
65
|
+
# Parameter is an array, so we need to iterate through it
|
66
|
+
data = nil
|
67
|
+
unless hash['data'].nil?
|
68
|
+
data = []
|
69
|
+
hash['data'].each do |structure|
|
70
|
+
data << (ModelEx.from_hash(structure) if structure)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
data = SKIP unless hash.key?('data')
|
75
|
+
|
76
|
+
# Create a new hash for additional properties, removing known properties.
|
77
|
+
new_hash = hash.reject { |k, _| names.value?(k) }
|
78
|
+
|
79
|
+
additional_properties = APIHelper.get_additional_properties(
|
80
|
+
new_hash, proc { |value| value }
|
81
|
+
)
|
82
|
+
|
83
|
+
# Create object from extracted values.
|
84
|
+
PaginatedResponseExListModelEx.new(page: page,
|
85
|
+
size: size,
|
86
|
+
data: data,
|
87
|
+
additional_properties: additional_properties)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Provides a human-readable string representation of the object.
|
91
|
+
def to_s
|
92
|
+
class_name = self.class.name.split('::').last
|
93
|
+
"<#{class_name} page: #{@page}, size: #{@size}, data: #{@data}, additional_properties:"\
|
94
|
+
" #{@additional_properties}>"
|
95
|
+
end
|
96
|
+
|
97
|
+
# Provides a debugging-friendly string with detailed object information.
|
98
|
+
def inspect
|
99
|
+
class_name = self.class.name.split('::').last
|
100
|
+
"<#{class_name} page: #{@page.inspect}, size: #{@size.inspect}, data: #{@data.inspect},"\
|
101
|
+
" additional_properties: #{@additional_properties}>"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# cuadra_ai
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module CuadraAi
|
7
|
+
# Tokens used
|
8
|
+
class TokensEx < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# Number of tokens of the request input
|
13
|
+
# @return [Integer]
|
14
|
+
attr_accessor :input_tokens
|
15
|
+
|
16
|
+
# Number of tokens of the response output
|
17
|
+
# @return [Integer]
|
18
|
+
attr_accessor :output_tokens
|
19
|
+
|
20
|
+
# A mapping from model property names to API property names.
|
21
|
+
def self.names
|
22
|
+
@_hash = {} if @_hash.nil?
|
23
|
+
@_hash['input_tokens'] = 'inputTokens'
|
24
|
+
@_hash['output_tokens'] = 'outputTokens'
|
25
|
+
@_hash
|
26
|
+
end
|
27
|
+
|
28
|
+
# An array for optional fields
|
29
|
+
def self.optionals
|
30
|
+
%w[
|
31
|
+
input_tokens
|
32
|
+
output_tokens
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
# An array for nullable fields
|
37
|
+
def self.nullables
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize(input_tokens: SKIP, output_tokens: SKIP,
|
42
|
+
additional_properties: nil)
|
43
|
+
# Add additional model properties to the instance
|
44
|
+
additional_properties = {} if additional_properties.nil?
|
45
|
+
|
46
|
+
@input_tokens = input_tokens unless input_tokens == SKIP
|
47
|
+
@output_tokens = output_tokens unless output_tokens == SKIP
|
48
|
+
@additional_properties = additional_properties
|
49
|
+
end
|
50
|
+
|
51
|
+
# Creates an instance of the object from a hash.
|
52
|
+
def self.from_hash(hash)
|
53
|
+
return nil unless hash
|
54
|
+
|
55
|
+
# Extract variables from the hash.
|
56
|
+
input_tokens = hash.key?('inputTokens') ? hash['inputTokens'] : SKIP
|
57
|
+
output_tokens = hash.key?('outputTokens') ? hash['outputTokens'] : SKIP
|
58
|
+
|
59
|
+
# Create a new hash for additional properties, removing known properties.
|
60
|
+
new_hash = hash.reject { |k, _| names.value?(k) }
|
61
|
+
|
62
|
+
additional_properties = APIHelper.get_additional_properties(
|
63
|
+
new_hash, proc { |value| value }
|
64
|
+
)
|
65
|
+
|
66
|
+
# Create object from extracted values.
|
67
|
+
TokensEx.new(input_tokens: input_tokens,
|
68
|
+
output_tokens: output_tokens,
|
69
|
+
additional_properties: additional_properties)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Provides a human-readable string representation of the object.
|
73
|
+
def to_s
|
74
|
+
class_name = self.class.name.split('::').last
|
75
|
+
"<#{class_name} input_tokens: #{@input_tokens}, output_tokens: #{@output_tokens},"\
|
76
|
+
" additional_properties: #{@additional_properties}>"
|
77
|
+
end
|
78
|
+
|
79
|
+
# Provides a debugging-friendly string with detailed object information.
|
80
|
+
def inspect
|
81
|
+
class_name = self.class.name.split('::').last
|
82
|
+
"<#{class_name} input_tokens: #{@input_tokens.inspect}, output_tokens:"\
|
83
|
+
" #{@output_tokens.inspect}, additional_properties: #{@additional_properties}>"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# cuadra_ai
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module CuadraAi
|
7
|
+
# TotalUsageEx Model.
|
8
|
+
class TotalUsageEx < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# Total Input Tokens used for this month
|
13
|
+
# @return [Integer]
|
14
|
+
attr_accessor :total_input
|
15
|
+
|
16
|
+
# Total Ouput Tokens used for this month
|
17
|
+
# @return [Integer]
|
18
|
+
attr_accessor :total_output
|
19
|
+
|
20
|
+
# A mapping from model property names to API property names.
|
21
|
+
def self.names
|
22
|
+
@_hash = {} if @_hash.nil?
|
23
|
+
@_hash['total_input'] = 'totalInput'
|
24
|
+
@_hash['total_output'] = 'totalOutput'
|
25
|
+
@_hash
|
26
|
+
end
|
27
|
+
|
28
|
+
# An array for optional fields
|
29
|
+
def self.optionals
|
30
|
+
%w[
|
31
|
+
total_input
|
32
|
+
total_output
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
# An array for nullable fields
|
37
|
+
def self.nullables
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize(total_input: SKIP, total_output: SKIP,
|
42
|
+
additional_properties: nil)
|
43
|
+
# Add additional model properties to the instance
|
44
|
+
additional_properties = {} if additional_properties.nil?
|
45
|
+
|
46
|
+
@total_input = total_input unless total_input == SKIP
|
47
|
+
@total_output = total_output unless total_output == SKIP
|
48
|
+
@additional_properties = additional_properties
|
49
|
+
end
|
50
|
+
|
51
|
+
# Creates an instance of the object from a hash.
|
52
|
+
def self.from_hash(hash)
|
53
|
+
return nil unless hash
|
54
|
+
|
55
|
+
# Extract variables from the hash.
|
56
|
+
total_input = hash.key?('totalInput') ? hash['totalInput'] : SKIP
|
57
|
+
total_output = hash.key?('totalOutput') ? hash['totalOutput'] : SKIP
|
58
|
+
|
59
|
+
# Create a new hash for additional properties, removing known properties.
|
60
|
+
new_hash = hash.reject { |k, _| names.value?(k) }
|
61
|
+
|
62
|
+
additional_properties = APIHelper.get_additional_properties(
|
63
|
+
new_hash, proc { |value| value }
|
64
|
+
)
|
65
|
+
|
66
|
+
# Create object from extracted values.
|
67
|
+
TotalUsageEx.new(total_input: total_input,
|
68
|
+
total_output: total_output,
|
69
|
+
additional_properties: additional_properties)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Provides a human-readable string representation of the object.
|
73
|
+
def to_s
|
74
|
+
class_name = self.class.name.split('::').last
|
75
|
+
"<#{class_name} total_input: #{@total_input}, total_output: #{@total_output},"\
|
76
|
+
" additional_properties: #{@additional_properties}>"
|
77
|
+
end
|
78
|
+
|
79
|
+
# Provides a debugging-friendly string with detailed object information.
|
80
|
+
def inspect
|
81
|
+
class_name = self.class.name.split('::').last
|
82
|
+
"<#{class_name} total_input: #{@total_input.inspect}, total_output:"\
|
83
|
+
" #{@total_output.inspect}, additional_properties: #{@additional_properties}>"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# cuadra_ai
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module CuadraAi
|
7
|
+
# UsageCalculationEx Model.
|
8
|
+
class UsageCalculationEx < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# Estimated tokens for your request
|
13
|
+
# @return [Integer]
|
14
|
+
attr_accessor :estimated_tokens
|
15
|
+
|
16
|
+
# A mapping from model property names to API property names.
|
17
|
+
def self.names
|
18
|
+
@_hash = {} if @_hash.nil?
|
19
|
+
@_hash['estimated_tokens'] = 'estimatedTokens'
|
20
|
+
@_hash
|
21
|
+
end
|
22
|
+
|
23
|
+
# An array for optional fields
|
24
|
+
def self.optionals
|
25
|
+
%w[
|
26
|
+
estimated_tokens
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
# An array for nullable fields
|
31
|
+
def self.nullables
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(estimated_tokens: SKIP, additional_properties: nil)
|
36
|
+
# Add additional model properties to the instance
|
37
|
+
additional_properties = {} if additional_properties.nil?
|
38
|
+
|
39
|
+
@estimated_tokens = estimated_tokens unless estimated_tokens == SKIP
|
40
|
+
@additional_properties = additional_properties
|
41
|
+
end
|
42
|
+
|
43
|
+
# Creates an instance of the object from a hash.
|
44
|
+
def self.from_hash(hash)
|
45
|
+
return nil unless hash
|
46
|
+
|
47
|
+
# Extract variables from the hash.
|
48
|
+
estimated_tokens =
|
49
|
+
hash.key?('estimatedTokens') ? hash['estimatedTokens'] : SKIP
|
50
|
+
|
51
|
+
# Create a new hash for additional properties, removing known properties.
|
52
|
+
new_hash = hash.reject { |k, _| names.value?(k) }
|
53
|
+
|
54
|
+
additional_properties = APIHelper.get_additional_properties(
|
55
|
+
new_hash, proc { |value| value }
|
56
|
+
)
|
57
|
+
|
58
|
+
# Create object from extracted values.
|
59
|
+
UsageCalculationEx.new(estimated_tokens: estimated_tokens,
|
60
|
+
additional_properties: additional_properties)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Provides a human-readable string representation of the object.
|
64
|
+
def to_s
|
65
|
+
class_name = self.class.name.split('::').last
|
66
|
+
"<#{class_name} estimated_tokens: #{@estimated_tokens}, additional_properties:"\
|
67
|
+
" #{@additional_properties}>"
|
68
|
+
end
|
69
|
+
|
70
|
+
# Provides a debugging-friendly string with detailed object information.
|
71
|
+
def inspect
|
72
|
+
class_name = self.class.name.split('::').last
|
73
|
+
"<#{class_name} estimated_tokens: #{@estimated_tokens.inspect}, additional_properties:"\
|
74
|
+
" #{@additional_properties}>"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|