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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +2 -1
- data/README.md +24 -0
- data/lib/cohere/client.rb +5 -4
- data/lib/cohere/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e2b7ec81e4c8f12d8f037913efd5ae99c72060eda6ae483c97f1dbe5d64fe153
|
|
4
|
+
data.tar.gz: e5f246ade127deb9802287b73525bc4ecaea9795ee8a9477753413132bf2e9bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
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
|
|
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
|
|
228
|
+
faraday.adapter(*Array(@adapter))
|
|
228
229
|
end
|
|
229
230
|
end
|
|
230
231
|
end
|
data/lib/cohere/version.rb
CHANGED
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.
|
|
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:
|
|
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.
|
|
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: []
|