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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +99 -0
  4. data/lib/cuadra_ai/api_helper.rb +10 -0
  5. data/lib/cuadra_ai/client.rb +91 -0
  6. data/lib/cuadra_ai/configuration.rb +105 -0
  7. data/lib/cuadra_ai/controllers/base_controller.rb +67 -0
  8. data/lib/cuadra_ai/controllers/chat_controller.rb +41 -0
  9. data/lib/cuadra_ai/controllers/embeds_controller.rb +41 -0
  10. data/lib/cuadra_ai/controllers/models_controller.rb +172 -0
  11. data/lib/cuadra_ai/controllers/oauth_authorization_controller.rb +87 -0
  12. data/lib/cuadra_ai/controllers/usage_controller.rb +70 -0
  13. data/lib/cuadra_ai/exceptions/api_exception.rb +21 -0
  14. data/lib/cuadra_ai/exceptions/error_response_exception.rb +57 -0
  15. data/lib/cuadra_ai/exceptions/oauth_provider_exception.rb +64 -0
  16. data/lib/cuadra_ai/http/api_response.rb +19 -0
  17. data/lib/cuadra_ai/http/auth/oauth_2.rb +139 -0
  18. data/lib/cuadra_ai/http/http_call_back.rb +10 -0
  19. data/lib/cuadra_ai/http/http_method_enum.rb +10 -0
  20. data/lib/cuadra_ai/http/http_request.rb +10 -0
  21. data/lib/cuadra_ai/http/http_response.rb +10 -0
  22. data/lib/cuadra_ai/logging/configuration/api_logging_configuration.rb +114 -0
  23. data/lib/cuadra_ai/logging/sdk_logger.rb +17 -0
  24. data/lib/cuadra_ai/models/base_model.rb +110 -0
  25. data/lib/cuadra_ai/models/chat.rb +102 -0
  26. data/lib/cuadra_ai/models/chat_response_ex.rb +106 -0
  27. data/lib/cuadra_ai/models/content_ex.rb +86 -0
  28. data/lib/cuadra_ai/models/embed.rb +100 -0
  29. data/lib/cuadra_ai/models/embed_response_ex.rb +85 -0
  30. data/lib/cuadra_ai/models/inline_data_ex.rb +87 -0
  31. data/lib/cuadra_ai/models/model_ex.rb +169 -0
  32. data/lib/cuadra_ai/models/oauth_provider_error.rb +45 -0
  33. data/lib/cuadra_ai/models/oauth_token.rb +96 -0
  34. data/lib/cuadra_ai/models/paginated_response_ex_list_model_ex.rb +104 -0
  35. data/lib/cuadra_ai/models/tokens_ex.rb +86 -0
  36. data/lib/cuadra_ai/models/total_usage_ex.rb +86 -0
  37. data/lib/cuadra_ai/models/usage_calculation_ex.rb +77 -0
  38. data/lib/cuadra_ai/models/usage_ex.rb +86 -0
  39. data/lib/cuadra_ai/utilities/date_time_helper.rb +11 -0
  40. data/lib/cuadra_ai/utilities/file_wrapper.rb +28 -0
  41. data/lib/cuadra_ai.rb +63 -0
  42. metadata +126 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6a2747b860c43f17574b00583eb1221d33ebf8bd1cadc1e6543d7379f9b3e9e0
4
+ data.tar.gz: 248b618cd2a26015751a8e812b0db2e180d5b09e02049a42ca3b42e94bb07cc5
5
+ SHA512:
6
+ metadata.gz: 9c76e9f0c65282d0595758fa1bf8b2499d04d79b8b7c3216044216823fdf7127372779295e40d32bae4d1a00aba84face9e14425cd824c0ece9da5ed984c898f
7
+ data.tar.gz: a9cc8f3ca271f34d20ec181973ff5275f91d2ae041608f70621fe16c7811d9ce7a11ec72bbdf2dc38d7a82afe5b54820187b29f540006c946b0b8689043f663c
data/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ License:
2
+ ========
3
+ The MIT License (MIT)
4
+ http://opensource.org/licenses/MIT
5
+
6
+ Copyright (c) 2014 - 2025 APIMATIC Limited
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
26
+ Trade Mark:
27
+ ==========
28
+ APIMATIC is a trade mark for APIMATIC Limited
data/README.md ADDED
@@ -0,0 +1,99 @@
1
+
2
+ # Getting Started with Cuadra AI
3
+
4
+ ## Introduction
5
+
6
+ API Documentation
7
+
8
+ ## Install the Package
9
+
10
+ Install the gem from the command line:
11
+
12
+ ```bash
13
+ gem install cuadra-ai-sdk -v 1.0.1
14
+ ```
15
+
16
+ Or add the gem to your Gemfile and run `bundle`:
17
+
18
+ ```ruby
19
+ gem 'cuadra-ai-sdk', '1.0.1'
20
+ ```
21
+
22
+ For additional gem details, see the [RubyGems page for the cuadra-ai-sdk gem](https://rubygems.org/gems/cuadra-ai-sdk/versions/1.0.1).
23
+
24
+ ## Initialize the API Client
25
+
26
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/client.md)
27
+
28
+ The following parameters are configurable for the API Client:
29
+
30
+ | Parameter | Type | Description |
31
+ | --- | --- | --- |
32
+ | environment | `Environment` | The API environment. <br> **Default: `Environment.PRODUCTION`** |
33
+ | connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
34
+ | adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
35
+ | timeout | `Float` | The value to use for connection timeout. <br> **Default: 30** |
36
+ | max_retries | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
37
+ | retry_interval | `Float` | Pause in seconds between retries. <br> **Default: 1** |
38
+ | backoff_factor | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
39
+ | retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
40
+ | retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
41
+ | http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
42
+ | logging_configuration | [`LoggingConfiguration`](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/logging-configuration.md) | The SDK logging configuration for API calls |
43
+ | authorization_code_auth_credentials | [`AuthorizationCodeAuthCredentials`](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/auth/oauth-2-authorization-code-grant.md) | The credential object for OAuth 2 Authorization Code Grant |
44
+
45
+ The API client can be initialized as follows:
46
+
47
+ ```ruby
48
+ client = CuadraAi::Client.new(
49
+ authorization_code_auth_credentials: AuthorizationCodeAuthCredentials.new(
50
+ oauth_client_id: 'OAuthClientId',
51
+ oauth_client_secret: 'OAuthClientSecret',
52
+ oauth_redirect_uri: 'OAuthRedirectUri'
53
+ ),
54
+ environment: Environment::PRODUCTION,
55
+ logging_configuration: LoggingConfiguration.new(
56
+ log_level: Logger::INFO,
57
+ request_logging_config: RequestLoggingConfiguration.new(
58
+ log_body: true
59
+ ),
60
+ response_logging_config: ResponseLoggingConfiguration.new(
61
+ log_headers: true
62
+ )
63
+ )
64
+ )
65
+ ```
66
+
67
+ ## Authorization
68
+
69
+ This API uses the following authentication schemes.
70
+
71
+ * [`OAuth2 (OAuth 2 Authorization Code Grant)`](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/auth/oauth-2-authorization-code-grant.md)
72
+
73
+ ## List of APIs
74
+
75
+ * [Chat](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/controllers/chat.md)
76
+ * [Models](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/controllers/models.md)
77
+ * [Embeds](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/controllers/embeds.md)
78
+ * [Usage](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/controllers/usage.md)
79
+
80
+ ## SDK Infrastructure
81
+
82
+ ### Configuration
83
+
84
+ * [AbstractLogger](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/abstract-logger.md)
85
+ * [LoggingConfiguration](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/logging-configuration.md)
86
+ * [RequestLoggingConfiguration](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/request-logging-configuration.md)
87
+ * [ResponseLoggingConfiguration](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/response-logging-configuration.md)
88
+
89
+ ### HTTP
90
+
91
+ * [HttpResponse](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/http-response.md)
92
+ * [HttpRequest](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/http-request.md)
93
+
94
+ ### Utilities
95
+
96
+ * [ApiResponse](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/api-response.md)
97
+ * [ApiHelper](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/api-helper.md)
98
+ * [DateTimeHelper](https://www.github.com/dan-cuadra-ai/cuadra-ai-ruby-sdk/tree/1.0.1/doc/date-time-helper.md)
99
+
@@ -0,0 +1,10 @@
1
+ # cuadra_ai
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CuadraAi
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,91 @@
1
+ # cuadra_ai
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CuadraAi
7
+ # cuadra_ai client class.
8
+ class Client
9
+ include CoreLibrary
10
+ attr_reader :config, :auth_managers
11
+
12
+ # Returns the configured authentication OAuth2 instance.
13
+ def oauth_2
14
+ @auth_managers['OAuth2']
15
+ end
16
+
17
+ # Access to chat controller.
18
+ # @return [ChatController] Returns the controller instance.
19
+ def chat
20
+ @chat ||= ChatController.new @global_configuration
21
+ end
22
+
23
+ # Access to models controller.
24
+ # @return [ModelsController] Returns the controller instance.
25
+ def models
26
+ @models ||= ModelsController.new @global_configuration
27
+ end
28
+
29
+ # Access to embeds controller.
30
+ # @return [EmbedsController] Returns the controller instance.
31
+ def embeds
32
+ @embeds ||= EmbedsController.new @global_configuration
33
+ end
34
+
35
+ # Access to usage controller.
36
+ # @return [UsageController] Returns the controller instance.
37
+ def usage
38
+ @usage ||= UsageController.new @global_configuration
39
+ end
40
+
41
+ # Access to oauth_authorization controller.
42
+ # @return [OauthAuthorizationController] Returns the controller instance.
43
+ def oauth_authorization
44
+ @oauth_authorization ||= OauthAuthorizationController.new @global_configuration
45
+ end
46
+
47
+ def initialize(
48
+ connection: nil, adapter: :net_http_persistent, timeout: 30,
49
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
50
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
51
+ retry_methods: %i[get put], http_callback: nil,
52
+ logging_configuration: nil, environment: Environment::PRODUCTION,
53
+ authorization_code_auth_credentials: nil, config: nil
54
+ )
55
+ @config = if config.nil?
56
+ Configuration.new(
57
+ connection: connection, adapter: adapter, timeout: timeout,
58
+ max_retries: max_retries, retry_interval: retry_interval,
59
+ backoff_factor: backoff_factor,
60
+ retry_statuses: retry_statuses,
61
+ retry_methods: retry_methods, http_callback: http_callback,
62
+ logging_configuration: logging_configuration,
63
+ environment: environment,
64
+ authorization_code_auth_credentials: authorization_code_auth_credentials
65
+ )
66
+ else
67
+ config
68
+ end
69
+ user_agent_params = BaseController.user_agent_parameters
70
+
71
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
72
+ .base_uri_executor(@config.method(:get_base_uri))
73
+ .global_errors(BaseController::GLOBAL_ERRORS)
74
+ .user_agent(BaseController.user_agent,
75
+ agent_parameters: user_agent_params)
76
+
77
+ initialize_auth_managers(@global_configuration)
78
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
79
+ end
80
+
81
+ # Initializes the auth managers hash used for authenticating API calls.
82
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
83
+ def initialize_auth_managers(global_config)
84
+ @auth_managers = {}
85
+ http_client_config = global_config.client_configuration
86
+ %w[OAuth2].each { |auth| @auth_managers[auth] = nil }
87
+ @auth_managers['OAuth2'] = Oauth2.new(http_client_config.authorization_code_auth_credentials,
88
+ global_config)
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,105 @@
1
+ # cuadra_ai
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CuadraAi
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ # PRODUCTION: Production Server
10
+ ENVIRONMENT = [
11
+ PRODUCTION = 'production'.freeze
12
+ ].freeze
13
+ end
14
+
15
+ # An enum for API servers.
16
+ class Server
17
+ SERVER = [
18
+ DEFAULT = 'default'.freeze,
19
+ AUTH_SERVER = 'auth server'.freeze
20
+ ].freeze
21
+ end
22
+
23
+ # All configuration including auth info and base URI for the API access
24
+ # are configured in this class.
25
+ class Configuration < CoreLibrary::HttpClientConfiguration
26
+ # The attribute readers for properties.
27
+ attr_reader :environment, :authorization_code_auth_credentials
28
+
29
+ class << self
30
+ attr_reader :environments
31
+ end
32
+
33
+ def initialize(
34
+ connection: nil, adapter: :net_http_persistent, timeout: 30,
35
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
36
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
37
+ retry_methods: %i[get put], http_callback: nil,
38
+ logging_configuration: nil, environment: Environment::PRODUCTION,
39
+ authorization_code_auth_credentials: nil
40
+ )
41
+ super connection: connection, adapter: adapter, timeout: timeout,
42
+ max_retries: max_retries, retry_interval: retry_interval,
43
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
44
+ retry_methods: retry_methods, http_callback: http_callback,
45
+ logging_configuration: logging_configuration
46
+
47
+ # Current API environment
48
+ @environment = String(environment)
49
+
50
+ # The object holding OAuth 2 Authorization Code Grant credentials
51
+ @authorization_code_auth_credentials = authorization_code_auth_credentials
52
+
53
+ # Initializing OAuth 2 Authorization Code Grant credentials with the provided auth parameters
54
+ @authorization_code_auth_credentials = authorization_code_auth_credentials
55
+
56
+ # The Http Client to use for making requests.
57
+ set_http_client CoreLibrary::FaradayClient.new(self)
58
+ end
59
+
60
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
61
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
62
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
63
+ logging_configuration: nil, environment: nil,
64
+ authorization_code_auth_credentials: nil)
65
+ connection ||= self.connection
66
+ adapter ||= self.adapter
67
+ timeout ||= self.timeout
68
+ max_retries ||= self.max_retries
69
+ retry_interval ||= self.retry_interval
70
+ backoff_factor ||= self.backoff_factor
71
+ retry_statuses ||= self.retry_statuses
72
+ retry_methods ||= self.retry_methods
73
+ http_callback ||= self.http_callback
74
+ logging_configuration ||= self.logging_configuration
75
+ environment ||= self.environment
76
+ authorization_code_auth_credentials ||= self.authorization_code_auth_credentials
77
+
78
+ Configuration.new(
79
+ connection: connection, adapter: adapter, timeout: timeout,
80
+ max_retries: max_retries, retry_interval: retry_interval,
81
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
82
+ retry_methods: retry_methods, http_callback: http_callback,
83
+ logging_configuration: logging_configuration, environment: environment,
84
+ authorization_code_auth_credentials: authorization_code_auth_credentials
85
+ )
86
+ end
87
+
88
+
89
+ # All the environments the SDK can run in.
90
+ ENVIRONMENTS = {
91
+ Environment::PRODUCTION => {
92
+ Server::DEFAULT => 'https://api.cuadra.ai',
93
+ Server::AUTH_SERVER => 'https://dguxglyyavnhlugtecgi.supabase.co/auth/v1'
94
+ }
95
+ }.freeze
96
+
97
+ # Generates the appropriate base URI for the environment and the server.
98
+ # @param [Configuration::Server] server The server enum for which the base URI is
99
+ # required.
100
+ # @return [String] The base URI.
101
+ def get_base_uri(server = Server::DEFAULT)
102
+ ENVIRONMENTS[environment][server].clone
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,67 @@
1
+ # cuadra_ai
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CuadraAi
7
+ # BaseController.
8
+ class BaseController
9
+ include CoreLibrary
10
+ attr_accessor :config, :http_call_back
11
+
12
+ def self.user_agent
13
+ 'Ruby-SDK/1.0.1 [OS: {os-info}, Engine: {engine}/{engine-version}]'
14
+ end
15
+
16
+ def self.user_agent_parameters
17
+ {
18
+ '{engine}' => { 'value' => RUBY_ENGINE, 'encode' => false },
19
+ '{engine-version}' => { 'value' => RUBY_ENGINE_VERSION, 'encode' => false },
20
+ '{os-info}' => { 'value' => RUBY_PLATFORM, 'encode' => false }
21
+ }
22
+ end
23
+
24
+ GLOBAL_ERRORS = {
25
+ 'default' => ErrorCase.new
26
+ .error_message('HTTP response not OK.')
27
+ .exception_type(APIException)
28
+ }.freeze
29
+
30
+ # Initialization constructor.
31
+ # @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
32
+ def initialize(global_configuration)
33
+ @global_configuration = global_configuration
34
+ @config = @global_configuration.client_configuration
35
+ @http_call_back = @config.http_callback
36
+ @api_call = ApiCall.new(@global_configuration)
37
+ end
38
+
39
+ # Creates a new instance of the request builder.
40
+ # @param [String] http_method The HTTP method to use in the request.
41
+ # @param [String] path The endpoint path to use in the request.
42
+ # @param [String] server The server to extract the base uri for the request.
43
+ # @return [RequestBuilder] The instance of RequestBuilder.
44
+ def new_request_builder(http_method, path, server)
45
+ RequestBuilder.new
46
+ .http_method(http_method)
47
+ .path(path)
48
+ .server(server)
49
+ end
50
+
51
+ # Creates a new instance of the response handler.
52
+ # @return [ResponseHandler] The instance of ResponseHandler.
53
+ def new_response_handler
54
+ ResponseHandler.new
55
+ end
56
+
57
+ # Creates a new instance of the parameter.
58
+ # @param [String|optional] key The key of the parameter.
59
+ # @param [Object] value The value of the parameter.
60
+ # @return [Parameter] The instance of Parameter.
61
+ def new_parameter(value, key: nil)
62
+ Parameter.new
63
+ .key(key)
64
+ .value(value)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,41 @@
1
+ # cuadra_ai
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CuadraAi
7
+ # ChatController
8
+ class ChatController < BaseController
9
+ # This endpoint creates a new chat interaction with our AI Models.
10
+ # @param [Chat] body Required parameter: TODO: type description here
11
+ # @return [ApiResponse] Complete http response with raw body and status code.
12
+ def chat(body)
13
+ @api_call
14
+ .request(new_request_builder(HttpMethodEnum::POST,
15
+ '/chat',
16
+ Server::DEFAULT)
17
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
18
+ .body_param(new_parameter(body)
19
+ .is_required(true))
20
+ .header_param(new_parameter('application/json', key: 'accept'))
21
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
22
+ .auth(Single.new('OAuth2')))
23
+ .response(new_response_handler
24
+ .deserializer(APIHelper.method(:custom_type_deserializer))
25
+ .deserialize_into(ChatResponseEx.method(:from_hash))
26
+ .is_api_response(true)
27
+ .local_error('400',
28
+ 'Bad request, read again our documentation or contact support'\
29
+ ' for guidance.',
30
+ ErrorResponseException)
31
+ .local_error('401',
32
+ 'Not authorized, check our OAuth2 doc.',
33
+ ErrorResponseException)
34
+ .local_error('500',
35
+ 'Internal error, if this error persist, please contact support'\
36
+ '.',
37
+ ErrorResponseException))
38
+ .execute
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ # cuadra_ai
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CuadraAi
7
+ # EmbedsController
8
+ class EmbedsController < BaseController
9
+ # This endpoint creates a new embed for training your custom AI Models.
10
+ # @param [Embed] body Required parameter: TODO: type description here
11
+ # @return [ApiResponse] Complete http response with raw body and status code.
12
+ def embed(body)
13
+ @api_call
14
+ .request(new_request_builder(HttpMethodEnum::POST,
15
+ '/embed',
16
+ Server::DEFAULT)
17
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
18
+ .body_param(new_parameter(body)
19
+ .is_required(true))
20
+ .header_param(new_parameter('application/json', key: 'accept'))
21
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
22
+ .auth(Single.new('OAuth2')))
23
+ .response(new_response_handler
24
+ .deserializer(APIHelper.method(:custom_type_deserializer))
25
+ .deserialize_into(EmbedResponseEx.method(:from_hash))
26
+ .is_api_response(true)
27
+ .local_error('400',
28
+ 'Bad request, read again our documentation or contact support'\
29
+ ' for guidance.',
30
+ ErrorResponseException)
31
+ .local_error('401',
32
+ 'Not authorized, check our OAuth2 doc.',
33
+ ErrorResponseException)
34
+ .local_error('500',
35
+ 'Internal error, if this error persist, please contact support'\
36
+ '.',
37
+ ErrorResponseException))
38
+ .execute
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,172 @@
1
+ # cuadra_ai
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module CuadraAi
7
+ # ModelsController
8
+ class ModelsController < BaseController
9
+ # This endpoint display all of our AI models.
10
+ # @param [Integer] page Optional parameter: TODO: type description here
11
+ # @param [Integer] size Optional parameter: TODO: type description here
12
+ # @return [ApiResponse] Complete http response with raw body and status code.
13
+ def get_models(page: nil,
14
+ size: nil)
15
+ @api_call
16
+ .request(new_request_builder(HttpMethodEnum::GET,
17
+ '/model',
18
+ Server::DEFAULT)
19
+ .query_param(new_parameter(page, key: 'page'))
20
+ .query_param(new_parameter(size, key: 'size'))
21
+ .header_param(new_parameter('application/json', key: 'accept'))
22
+ .auth(Single.new('OAuth2')))
23
+ .response(new_response_handler
24
+ .deserializer(APIHelper.method(:custom_type_deserializer))
25
+ .deserialize_into(PaginatedResponseExListModelEx.method(:from_hash))
26
+ .is_api_response(true)
27
+ .local_error('400',
28
+ 'Bad request, read again our documentation or contact support'\
29
+ ' for guidance.',
30
+ ErrorResponseException)
31
+ .local_error('401',
32
+ 'Not authorized, check our OAuth2 doc.',
33
+ ErrorResponseException)
34
+ .local_error('500',
35
+ 'Internal error, if this error persist, please contact support'\
36
+ '.',
37
+ ErrorResponseException))
38
+ .execute
39
+ end
40
+
41
+ # This endpoint creates a new custom Model for you to train and use.
42
+ # @param [ModelEx] body Required parameter: TODO: type description here
43
+ # @return [ApiResponse] Complete http response with raw body and status code.
44
+ def create_model(body)
45
+ @api_call
46
+ .request(new_request_builder(HttpMethodEnum::POST,
47
+ '/model',
48
+ Server::DEFAULT)
49
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
50
+ .body_param(new_parameter(body)
51
+ .is_required(true))
52
+ .header_param(new_parameter('application/json', key: 'accept'))
53
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
54
+ .auth(Single.new('OAuth2')))
55
+ .response(new_response_handler
56
+ .deserializer(APIHelper.method(:custom_type_deserializer))
57
+ .deserialize_into(ModelEx.method(:from_hash))
58
+ .is_api_response(true)
59
+ .local_error('400',
60
+ 'Bad request, read again our documentation or contact support'\
61
+ ' for guidance.',
62
+ ErrorResponseException)
63
+ .local_error('401',
64
+ 'Not authorized, check our OAuth2 doc.',
65
+ ErrorResponseException)
66
+ .local_error('500',
67
+ 'Internal error, if this error persist, please contact support'\
68
+ '.',
69
+ ErrorResponseException))
70
+ .execute
71
+ end
72
+
73
+ # This endpoint shows you information about a particular model given an id.
74
+ # @param [String] id Required parameter: TODO: type description here
75
+ # @return [ApiResponse] Complete http response with raw body and status code.
76
+ def get_model(id)
77
+ @api_call
78
+ .request(new_request_builder(HttpMethodEnum::GET,
79
+ '/model/{id}',
80
+ Server::DEFAULT)
81
+ .template_param(new_parameter(id, key: 'id')
82
+ .is_required(true)
83
+ .should_encode(true))
84
+ .header_param(new_parameter('application/json', key: 'accept'))
85
+ .auth(Single.new('OAuth2')))
86
+ .response(new_response_handler
87
+ .deserializer(APIHelper.method(:custom_type_deserializer))
88
+ .deserialize_into(ModelEx.method(:from_hash))
89
+ .is_api_response(true)
90
+ .local_error('400',
91
+ 'Bad request, read again our documentation or contact support'\
92
+ ' for guidance.',
93
+ ErrorResponseException)
94
+ .local_error('401',
95
+ 'Not authorized, check our OAuth2 doc.',
96
+ ErrorResponseException)
97
+ .local_error('500',
98
+ 'Internal error, if this error persist, please contact support'\
99
+ '.',
100
+ ErrorResponseException))
101
+ .execute
102
+ end
103
+
104
+ # This endpoint removes a custom model you created.
105
+ # @param [String] id Required parameter: TODO: type description here
106
+ # @return [ApiResponse] Complete http response with raw body and status code.
107
+ def remove_model(id)
108
+ @api_call
109
+ .request(new_request_builder(HttpMethodEnum::DELETE,
110
+ '/model/{id}',
111
+ Server::DEFAULT)
112
+ .template_param(new_parameter(id, key: 'id')
113
+ .is_required(true)
114
+ .should_encode(true))
115
+ .header_param(new_parameter('application/json', key: 'accept'))
116
+ .auth(Single.new('OAuth2')))
117
+ .response(new_response_handler
118
+ .deserializer(APIHelper.method(:custom_type_deserializer))
119
+ .deserialize_into(ModelEx.method(:from_hash))
120
+ .is_api_response(true)
121
+ .local_error('400',
122
+ 'Bad request, read again our documentation or contact support'\
123
+ ' for guidance.',
124
+ ErrorResponseException)
125
+ .local_error('401',
126
+ 'Not authorized, check our OAuth2 doc.',
127
+ ErrorResponseException)
128
+ .local_error('500',
129
+ 'Internal error, if this error persist, please contact support'\
130
+ '.',
131
+ ErrorResponseException))
132
+ .execute
133
+ end
134
+
135
+ # This endpoint updates a custom model you created.
136
+ # @param [String] id Required parameter: TODO: type description here
137
+ # @param [ModelEx] body Required parameter: TODO: type description here
138
+ # @return [ApiResponse] Complete http response with raw body and status code.
139
+ def update_model(id,
140
+ body)
141
+ @api_call
142
+ .request(new_request_builder(HttpMethodEnum::PATCH,
143
+ '/model/{id}',
144
+ Server::DEFAULT)
145
+ .template_param(new_parameter(id, key: 'id')
146
+ .is_required(true)
147
+ .should_encode(true))
148
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
149
+ .body_param(new_parameter(body)
150
+ .is_required(true))
151
+ .header_param(new_parameter('application/json', key: 'accept'))
152
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
153
+ .auth(Single.new('OAuth2')))
154
+ .response(new_response_handler
155
+ .deserializer(APIHelper.method(:custom_type_deserializer))
156
+ .deserialize_into(ModelEx.method(:from_hash))
157
+ .is_api_response(true)
158
+ .local_error('400',
159
+ 'Bad request, read again our documentation or contact support'\
160
+ ' for guidance.',
161
+ ErrorResponseException)
162
+ .local_error('401',
163
+ 'Not authorized, check our OAuth2 doc.',
164
+ ErrorResponseException)
165
+ .local_error('500',
166
+ 'Internal error, if this error persist, please contact support'\
167
+ '.',
168
+ ErrorResponseException))
169
+ .execute
170
+ end
171
+ end
172
+ end