cohere-ruby 0.9.9 → 0.9.10

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: 35acc85a1ec589048eae603675fd23afeec9c66c0ce8c14954c20916c099b93b
4
- data.tar.gz: e48ea97c36afafa8ca134c240a19ff159af1086643e99efba0aaf5aaed225cca
3
+ metadata.gz: 6c5f0625529c315bd0a953bb8e0acf36fbebe685b13decde1fe26d93b5d97ab8
4
+ data.tar.gz: 504ce83377f6f2175b2d7ab9f899c307a7a02563c75b8c630b249d0e7487c746
5
5
  SHA512:
6
- metadata.gz: eb6700a2088e5b37842fb6a601e160bbc6e8a6e8c15a7dd52b42f74cc0ce5fc71c77d789d9eaa20a440b1a3c4b4bab46088a5117b84d0a5027531acbfaf28067
7
- data.tar.gz: 4e759bd938560031412e4602ee86321e3953e61dfa9c368c843b0d1b71e0676b061007dda48514b8ef5e9df072f7df3b5c817452f06a72553864bf77a679b492
6
+ metadata.gz: 1dc8c2c85e551438f597346679c3bb198808e906eb9317dd05c26511556e34f512707cbc4bb3046487de9e498ca7b92c6405d2f9c3e4175f466e49618c7215b9
7
+ data.tar.gz: 0024a4c8c6091fa78fe83dcd7879ea8a511436e4ddc16929dd3e88e517901ba1ac569e16c519f47abccbba08a0cdd43fe795c4e867b4e252f0d5003a9ffb5b3e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.9.10] - 2024-05-10
4
+ - /chat endpoint does not require `message:` parameter anymore
5
+
3
6
  ## [0.9.9] - 2024-04-05
4
7
  - Adding missing parameters to endpoints
5
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cohere-ruby (0.9.9)
4
+ cohere-ruby (0.9.10)
5
5
  faraday (>= 2.0.1, < 3.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -34,7 +34,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
34
34
  require "cohere"
35
35
 
36
36
  client = Cohere::Client.new(
37
- ENV['COHERE_API_KEY']
37
+ api_key: ENV['COHERE_API_KEY']
38
38
  )
39
39
  ```
40
40
 
data/lib/cohere/client.rb CHANGED
@@ -8,12 +8,13 @@ module Cohere
8
8
 
9
9
  ENDPOINT_URL = "https://api.cohere.ai/v1"
10
10
 
11
- def initialize(api_key)
11
+ def initialize(api_key:, timeout: nil)
12
12
  @api_key = api_key
13
+ @timeout = timeout
13
14
  end
14
15
 
15
16
  def chat(
16
- message:,
17
+ message: nil,
17
18
  model: nil,
18
19
  stream: false,
19
20
  preamble: nil,
@@ -29,13 +30,16 @@ module Cohere
29
30
  max_tokens: nil,
30
31
  k: nil,
31
32
  p: nil,
33
+ seed: nil,
32
34
  frequency_penalty: nil,
33
35
  presence_penalty: nil,
34
36
  tools: [],
35
37
  &block
36
38
  )
37
39
  response = connection.post("chat") do |req|
38
- req.body = {message: message}
40
+ req.body = {}
41
+
42
+ req.body[:message] = message if message
39
43
  req.body[:model] = model if model
40
44
  if stream || block
41
45
  req.body[:stream] = true
@@ -54,6 +58,7 @@ module Cohere
54
58
  req.body[:max_tokens] = max_tokens if max_tokens
55
59
  req.body[:k] = k if k
56
60
  req.body[:p] = p if p
61
+ req.body[:seed] = seed if seed
57
62
  req.body[:frequency_penalty] = frequency_penalty if frequency_penalty
58
63
  req.body[:presence_penalty] = presence_penalty if presence_penalty
59
64
  req.body[:tools] = tools if tools
@@ -179,7 +184,7 @@ module Cohere
179
184
 
180
185
  # standard:disable Lint/DuplicateMethods
181
186
  def connection
182
- @connection ||= Faraday.new(url: ENDPOINT_URL) do |faraday|
187
+ @connection ||= Faraday.new(url: ENDPOINT_URL, request: {timeout: @timeout}) do |faraday|
183
188
  if api_key
184
189
  faraday.request :authorization, :Bearer, api_key
185
190
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cohere
4
- VERSION = "0.9.9"
4
+ VERSION = "0.9.10"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cohere-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Bondarev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
11
+ date: 2024-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday