maritaca-ai 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 528dad62e33505dbe008d7a4a2829f8d0fb91d7ae621884cf4eb436777785589
4
- data.tar.gz: fa2f39f286f091d238aee2ba8da22419c0880867892139a8d2c581f78d10f3f4
3
+ metadata.gz: 6303b41bc438b8e903a651e906e695cca755c34820cb75c66a9f669b2b8bedc4
4
+ data.tar.gz: cf98f0c7cdd2580885e681077fb57d15c78b68d6908176bc1cff8b737adff174
5
5
  SHA512:
6
- metadata.gz: 23cb4d50db7d60142fe05313031c16096200b59ff7d10fb4bc51316b64396085d28a4916f2402bc9ff9ada668beb914e701a0b384297a5fd7b47e68a76112610
7
- data.tar.gz: 0b0a0ab8c1d4f3f5d69ac0a95a5e63533419f4fb64ca70ffc882bc9e87d8a3867ae68a4d865b7a2a0546869eb2d479a5404cf8aa01025fd4e7ebe56530cee5fa
6
+ metadata.gz: e2107ca61810c3ac4c0ef71955cfd998b71451a6dd2c0ef91a3442448a38f0594d4791687c5852bf668736c5f5a3b9f954932f601cd7629c8e871592cc8a7002
7
+ data.tar.gz: bde4023b33d3afbd36cbe183a60c14fd558135d99f323686a8130b98e601d9910af4e3d81f97a08a49ffd51d1ecbec68704d3772c86c6f2a2fdaa27f982335d1
data/Gemfile CHANGED
@@ -7,5 +7,5 @@ gemspec
7
7
  group :test, :development do
8
8
  gem 'dotenv', '~> 2.8', '>= 2.8.1'
9
9
  gem 'pry-byebug', '~> 3.10', '>= 3.10.1'
10
- gem 'rubocop', '~> 1.58'
10
+ gem 'rubocop', '~> 1.60', '>= 1.60.2'
11
11
  end
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maritaca-ai (1.0.1)
4
+ maritaca-ai (1.1.0)
5
5
  faraday (~> 2.9)
6
+ faraday-typhoeus (~> 1.1)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
@@ -11,17 +12,23 @@ GEM
11
12
  byebug (11.1.3)
12
13
  coderay (1.1.3)
13
14
  dotenv (2.8.1)
15
+ ethon (0.16.0)
16
+ ffi (>= 1.15.0)
14
17
  faraday (2.9.0)
15
18
  faraday-net_http (>= 2.0, < 3.2)
16
19
  faraday-net_http (3.1.0)
17
20
  net-http
21
+ faraday-typhoeus (1.1.0)
22
+ faraday (~> 2.0)
23
+ typhoeus (~> 1.4)
24
+ ffi (1.16.3)
18
25
  json (2.7.1)
19
26
  language_server-protocol (3.17.0.3)
20
27
  method_source (1.0.0)
21
28
  net-http (0.4.1)
22
29
  uri
23
30
  parallel (1.24.0)
24
- parser (3.3.0.3)
31
+ parser (3.3.0.5)
25
32
  ast (~> 2.4.1)
26
33
  racc
27
34
  pry (0.14.2)
@@ -34,11 +41,11 @@ GEM
34
41
  rainbow (3.1.1)
35
42
  regexp_parser (2.9.0)
36
43
  rexml (3.2.6)
37
- rubocop (1.59.0)
44
+ rubocop (1.60.2)
38
45
  json (~> 2.3)
39
46
  language_server-protocol (>= 3.17.0)
40
47
  parallel (~> 1.10)
41
- parser (>= 3.2.2.4)
48
+ parser (>= 3.3.0.2)
42
49
  rainbow (>= 2.2.2, < 4.0)
43
50
  regexp_parser (>= 1.8, < 3.0)
44
51
  rexml (>= 3.2.5, < 4.0)
@@ -48,6 +55,8 @@ GEM
48
55
  rubocop-ast (1.30.0)
49
56
  parser (>= 3.2.1.0)
50
57
  ruby-progressbar (1.13.0)
58
+ typhoeus (1.4.1)
59
+ ethon (>= 0.9.0)
51
60
  unicode-display_width (2.5.0)
52
61
  uri (0.13.0)
53
62
 
@@ -58,7 +67,7 @@ DEPENDENCIES
58
67
  dotenv (~> 2.8, >= 2.8.1)
59
68
  maritaca-ai!
60
69
  pry-byebug (~> 3.10, >= 3.10.1)
61
- rubocop (~> 1.58)
70
+ rubocop (~> 1.60, >= 1.60.2)
62
71
 
63
72
  BUNDLED WITH
64
73
  2.4.22
data/README.md CHANGED
@@ -9,7 +9,7 @@ A Ruby gem for interacting with [MariTalk](https://chat.maritaca.ai) from [Marit
9
9
  ## TL;DR and Quick Start
10
10
 
11
11
  ```ruby
12
- gem 'maritaca-ai', '~> 1.0.1'
12
+ gem 'maritaca-ai', '~> 1.1.0'
13
13
  ```
14
14
 
15
15
  ```ruby
@@ -36,27 +36,28 @@ Result:
36
36
  - [TL;DR and Quick Start](#tldr-and-quick-start)
37
37
  - [Index](#index)
38
38
  - [Setup](#setup)
39
- - [Installing](#installing)
40
- - [Credentials](#credentials)
39
+ - [Installing](#installing)
40
+ - [Credentials](#credentials)
41
41
  - [Usage](#usage)
42
- - [Client](#client)
43
- - [Custom Address](#custom-address)
44
- - [Methods](#methods)
45
- - [chat_inference](#chat_inference)
46
- - [Chat](#chat)
47
- - [Back-and-Forth Conversations](#back-and-forth-conversations)
48
- - [Without Chat](#without-chat)
49
- - [New Functionalities and APIs](#new-functionalities-and-apis)
50
- - [Request Options](#request-options)
51
- - [Timeout](#timeout)
52
- - [Error Handling](#error-handling)
53
- - [Rescuing](#rescuing)
54
- - [For Short](#for-short)
55
- - [Errors](#errors)
42
+ - [Client](#client)
43
+ - [Custom Address](#custom-address)
44
+ - [Methods](#methods)
45
+ - [chat_inference](#chat_inference)
46
+ - [Chat](#chat)
47
+ - [Back-and-Forth Conversations](#back-and-forth-conversations)
48
+ - [Without Chat](#without-chat)
49
+ - [New Functionalities and APIs](#new-functionalities-and-apis)
50
+ - [Request Options](#request-options)
51
+ - [Adapter](#adapter)
52
+ - [Timeout](#timeout)
53
+ - [Error Handling](#error-handling)
54
+ - [Rescuing](#rescuing)
55
+ - [For Short](#for-short)
56
+ - [Errors](#errors)
56
57
  - [Development](#development)
57
- - [Purpose](#purpose)
58
- - [Publish to RubyGems](#publish-to-rubygems)
59
- - [Updating the README](#updating-the-readme)
58
+ - [Purpose](#purpose)
59
+ - [Publish to RubyGems](#publish-to-rubygems)
60
+ - [Updating the README](#updating-the-readme)
60
61
  - [Resources and References](#resources-and-references)
61
62
  - [Disclaimer](#disclaimer)
62
63
 
@@ -65,11 +66,11 @@ Result:
65
66
  ### Installing
66
67
 
67
68
  ```sh
68
- gem install maritaca-ai -v 1.0.1
69
+ gem install maritaca-ai -v 1.1.0
69
70
  ```
70
71
 
71
72
  ```sh
72
- gem 'maritaca-ai', '~> 1.0.1'
73
+ gem 'maritaca-ai', '~> 1.1.0'
73
74
  ```
74
75
 
75
76
  ### Credentials
@@ -187,6 +188,21 @@ result = client.request(
187
188
 
188
189
  ### Request Options
189
190
 
191
+ #### Adapter
192
+
193
+ The gem uses [Faraday](https://github.com/lostisland/faraday) with the [Typhoeus](https://github.com/typhoeus/typhoeus) adapter by default.
194
+
195
+ You can use a different adapter if you want:
196
+
197
+ ```ruby
198
+ require 'faraday/net_http'
199
+
200
+ client = Maritaca.new(
201
+ credentials: { api_key: ENV['MARITACA_API_KEY'] },
202
+ options: { connection: { adapter: :net_http } }
203
+ )
204
+ ```
205
+
190
206
  #### Timeout
191
207
 
192
208
  You can set the maximum number of seconds to wait for the request to complete with the `timeout` option:
@@ -290,7 +306,7 @@ gem build maritaca-ai.gemspec
290
306
 
291
307
  gem signin
292
308
 
293
- gem push maritaca-ai-1.0.1.gem
309
+ gem push maritaca-ai-1.1.0.gem
294
310
  ```
295
311
 
296
312
  ### Updating the README
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'faraday'
4
+ require 'faraday/typhoeus'
4
5
  require 'json'
5
6
 
6
7
  require_relative '../components/errors'
@@ -12,6 +13,8 @@ module Maritaca
12
13
 
13
14
  ALLOWED_REQUEST_OPTIONS = %i[timeout open_timeout read_timeout write_timeout].freeze
14
15
 
16
+ DEFAULT_FARADAY_ADAPTER = :typhoeus
17
+
15
18
  def initialize(config)
16
19
  @api_key = config.dig(:credentials, :api_key)
17
20
  @server_sent_events = config.dig(:options, :server_sent_events)
@@ -35,6 +38,8 @@ module Maritaca
35
38
  else
36
39
  {}
37
40
  end
41
+
42
+ @faraday_adapter = config.dig(:options, :connection, :adapter) || DEFAULT_FARADAY_ADAPTER
38
43
  end
39
44
 
40
45
  def chat_inference(payload, server_sent_events: nil, &callback)
@@ -57,6 +62,7 @@ module Maritaca
57
62
  partial_json = ''
58
63
 
59
64
  response = Faraday.new(request: @request_options) do |faraday|
65
+ faraday.adapter @faraday_adapter
60
66
  faraday.response :raise_error
61
67
  end.send(method_to_call) do |request|
62
68
  request.url url
data/maritaca-ai.gemspec CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ['ports/dsl']
31
31
 
32
32
  spec.add_dependency 'faraday', '~> 2.9'
33
+ spec.add_dependency 'faraday-typhoeus', '~> 1.1'
33
34
 
34
35
  spec.metadata['rubygems_mfa_required'] = 'true'
35
36
  end
data/static/gem.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Maritaca
4
4
  GEM = {
5
5
  name: 'maritaca-ai',
6
- version: '1.0.1',
6
+ version: '1.1.0',
7
7
  author: 'gbaptista',
8
8
  summary: 'Interact with Maritaca AI.',
9
9
  description: "A Ruby gem for interacting with Maritaca AI's large language models.",
@@ -23,7 +23,7 @@
23
23
  (remove nil?))]
24
24
  (->> processed-lines
25
25
  (map (fn [{:keys [level title link]}]
26
- (str (apply str (repeat (* 4 (- level 2)) " "))
26
+ (str (apply str (repeat (* 2 (- level 2)) " "))
27
27
  "- ["
28
28
  title
29
29
  "](#"
data/template.md CHANGED
@@ -9,7 +9,7 @@ A Ruby gem for interacting with [MariTalk](https://chat.maritaca.ai) from [Marit
9
9
  ## TL;DR and Quick Start
10
10
 
11
11
  ```ruby
12
- gem 'maritaca-ai', '~> 1.0.1'
12
+ gem 'maritaca-ai', '~> 1.1.0'
13
13
  ```
14
14
 
15
15
  ```ruby
@@ -40,11 +40,11 @@ Result:
40
40
  ### Installing
41
41
 
42
42
  ```sh
43
- gem install maritaca-ai -v 1.0.1
43
+ gem install maritaca-ai -v 1.1.0
44
44
  ```
45
45
 
46
46
  ```sh
47
- gem 'maritaca-ai', '~> 1.0.1'
47
+ gem 'maritaca-ai', '~> 1.1.0'
48
48
  ```
49
49
 
50
50
  ### Credentials
@@ -162,6 +162,21 @@ result = client.request(
162
162
 
163
163
  ### Request Options
164
164
 
165
+ #### Adapter
166
+
167
+ The gem uses [Faraday](https://github.com/lostisland/faraday) with the [Typhoeus](https://github.com/typhoeus/typhoeus) adapter by default.
168
+
169
+ You can use a different adapter if you want:
170
+
171
+ ```ruby
172
+ require 'faraday/net_http'
173
+
174
+ client = Maritaca.new(
175
+ credentials: { api_key: ENV['MARITACA_API_KEY'] },
176
+ options: { connection: { adapter: :net_http } }
177
+ )
178
+ ```
179
+
165
180
  #### Timeout
166
181
 
167
182
  You can set the maximum number of seconds to wait for the request to complete with the `timeout` option:
@@ -265,7 +280,7 @@ gem build maritaca-ai.gemspec
265
280
 
266
281
  gem signin
267
282
 
268
- gem push maritaca-ai-1.0.1.gem
283
+ gem push maritaca-ai-1.1.0.gem
269
284
  ```
270
285
 
271
286
  ### Updating the README
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maritaca-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gbaptista
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-13 00:00:00.000000000 Z
11
+ date: 2024-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -24,8 +24,22 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday-typhoeus
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
27
41
  description: A Ruby gem for interacting with Maritaca AI's large language models.
28
- email:
42
+ email:
29
43
  executables: []
30
44
  extensions: []
31
45
  extra_rdoc_files: []
@@ -53,7 +67,7 @@ metadata:
53
67
  homepage_uri: https://github.com/gbaptista/maritaca-ai
54
68
  source_code_uri: https://github.com/gbaptista/maritaca-ai
55
69
  rubygems_mfa_required: 'true'
56
- post_install_message:
70
+ post_install_message:
57
71
  rdoc_options: []
58
72
  require_paths:
59
73
  - ports/dsl
@@ -69,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
83
  version: '0'
70
84
  requirements: []
71
85
  rubygems_version: 3.3.3
72
- signing_key:
86
+ signing_key:
73
87
  specification_version: 4
74
88
  summary: Interact with Maritaca AI.
75
89
  test_files: []