cohere-ruby 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c65ac65e6fa623709455907a71697f721311d2933e96a10a5c49f907f356f02
4
- data.tar.gz: 553fd85c32a2a99b2a8d1a75f1a2aa0a0c9abec290f305ed26caa855515f717b
3
+ metadata.gz: e2b7ec81e4c8f12d8f037913efd5ae99c72060eda6ae483c97f1dbe5d64fe153
4
+ data.tar.gz: e5f246ade127deb9802287b73525bc4ecaea9795ee8a9477753413132bf2e9bd
5
5
  SHA512:
6
- metadata.gz: bb7dd10864d789f91225f9370011e622dc6353a55a7039b8ef509610980c1503c3916f210189361cc1dcc20cb1db880d7fd4d80f967867fdcecd6803e85e8bdb
7
- data.tar.gz: 89eb351c192abfda2c905810210b21be5d6a5b18aa6e3d5a4ac28efaba9fc23e1a0525510b51a4399c5e7086fab12a854035388806c4401122c3463277941990
6
+ metadata.gz: 351b92766fe85087c7efeb2e01bcef4972575467b4bfb4c3b9611b5b6ccf3c4f280a9fc0560b3f8ff9fd7ea1219e1ee04fa6c43ba8386cb860b23e6d8677c453
7
+ data.tar.gz: 499e3b50697dfd688fa8416202cad430b42fb044f3d19418a83ff63731e4fad8edac596c774039893d2fbce34120fdd9ac9b95a4f023517d0b32cf1e5e9e9ddd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.0.2] - 2026-04-27
4
+ - Add `adapter:` keyword argument to `Cohere::Client.new` for configuring the Faraday HTTP adapter (defaults to `Faraday.default_adapter`). Enables using persistent adapters such as `:net_http_persistent` to amortize TCP/TLS handshakes across requests.
5
+
3
6
  ## [1.0.1] - 2024-11-22
4
7
 
5
8
  ## [1.0.0] - 2024-11-22
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cohere-ruby (1.0.1)
4
+ cohere-ruby (1.0.2)
5
5
  faraday (>= 2.0.1, < 3.0)
6
6
 
7
7
  GEM
@@ -69,6 +69,7 @@ GEM
69
69
 
70
70
  PLATFORMS
71
71
  arm64-darwin-23
72
+ arm64-darwin-24
72
73
  x86_64-darwin-19
73
74
  x86_64-darwin-21
74
75
  x86_64-linux
data/README.md CHANGED
@@ -38,6 +38,30 @@ client = Cohere::Client.new(
38
38
  )
39
39
  ```
40
40
 
41
+ #### Custom HTTP adapter
42
+
43
+ By default the client uses `Faraday.default_adapter` (Net::HTTP), which opens a
44
+ new TCP/TLS connection per request. For high-throughput use cases, pass a
45
+ persistent adapter to reuse connections across requests:
46
+
47
+ ```ruby
48
+ require "faraday/net_http_persistent"
49
+
50
+ client = Cohere::Client.new(
51
+ api_key: ENV['COHERE_API_KEY'],
52
+ adapter: :net_http_persistent
53
+ )
54
+ ```
55
+
56
+ You can also pass adapter options:
57
+
58
+ ```ruby
59
+ client = Cohere::Client.new(
60
+ api_key: ENV['COHERE_API_KEY'],
61
+ adapter: [:net_http_persistent, {name: "cohere", pool_size: 10}]
62
+ )
63
+ ```
64
+
41
65
  ### Generate
42
66
 
43
67
  ```ruby
data/lib/cohere/client.rb CHANGED
@@ -4,11 +4,12 @@ require "faraday"
4
4
 
5
5
  module Cohere
6
6
  class Client
7
- attr_reader :api_key, :connection
7
+ attr_reader :api_key, :connection, :adapter
8
8
 
9
- def initialize(api_key:, timeout: nil)
9
+ def initialize(api_key:, timeout: nil, adapter: Faraday.default_adapter)
10
10
  @api_key = api_key
11
11
  @timeout = timeout
12
+ @adapter = adapter
12
13
  end
13
14
 
14
15
  # Generates a text response to a user message and streams it down, token by token
@@ -215,7 +216,7 @@ module Cohere
215
216
  faraday.request :authorization, :Bearer, api_key
216
217
  faraday.request :json
217
218
  faraday.response :json, content_type: /\bjson$/
218
- faraday.adapter Faraday.default_adapter
219
+ faraday.adapter(*Array(@adapter))
219
220
  end
220
221
  end
221
222
 
@@ -224,7 +225,7 @@ module Cohere
224
225
  faraday.request :authorization, :Bearer, api_key
225
226
  faraday.request :json
226
227
  faraday.response :json, content_type: /\bjson$/
227
- faraday.adapter Faraday.default_adapter
228
+ faraday.adapter(*Array(@adapter))
228
229
  end
229
230
  end
230
231
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cohere
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cohere-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Bondarev
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-11-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: faraday
@@ -56,7 +55,6 @@ metadata:
56
55
  homepage_uri: https://github.com/andreibondarev/cohere-ruby
57
56
  source_code_uri: https://github.com/andreibondarev/cohere-ruby
58
57
  changelog_uri: https://github.com/andreibondarev/cohere-ruby/CHANGELOG.md
59
- post_install_message:
60
58
  rdoc_options: []
61
59
  require_paths:
62
60
  - lib
@@ -71,8 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
69
  - !ruby/object:Gem::Version
72
70
  version: '0'
73
71
  requirements: []
74
- rubygems_version: 3.5.11
75
- signing_key:
72
+ rubygems_version: 3.6.9
76
73
  specification_version: 4
77
74
  summary: Cohere API client for Ruby.
78
75
  test_files: []