cohere-ruby 0.9.6 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +2 -1
- data/README.md +8 -1
- data/lib/cohere/client.rb +44 -1
- data/lib/cohere/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83208ee6cbdf496180ac2e6ed258388a74a266d86188b81ceb011bf5f2b61f44
|
4
|
+
data.tar.gz: 9f0ff2d20ea3c988663bc1c104f46f0c94a6d8d833d4a0ebf1cb81f765d8502d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0425fe338748ba829c6d15b3fe319c23cf6fe47ab18c885476dcccffe969888c215162d9139768e53ed569b5e6799c9abc17ecb028551f3cd48c2f92cec49e6
|
7
|
+
data.tar.gz: 48add01bf4d9ee6a43ee27809efe2eb352eee73bceac26b6fcfff29ae060063b8e3f4dc5803e317d80a612d0f6890ac18ca1d90cf5fd62254e3d1bc6f1dce8de
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cohere-ruby (0.9.
|
4
|
+
cohere-ruby (0.9.8)
|
5
5
|
faraday (>= 2.0.1, < 3.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -67,6 +67,7 @@ GEM
|
|
67
67
|
unicode-display_width (2.4.2)
|
68
68
|
|
69
69
|
PLATFORMS
|
70
|
+
arm64-darwin-23
|
70
71
|
x86_64-darwin-19
|
71
72
|
x86_64-darwin-21
|
72
73
|
x86_64-linux
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
33
33
|
require "cohere"
|
34
34
|
|
35
35
|
client = Cohere::Client.new(
|
36
|
-
|
36
|
+
ENV['COHERE_API_KEY']
|
37
37
|
)
|
38
38
|
```
|
39
39
|
### Generate
|
@@ -43,6 +43,13 @@ client.generate(
|
|
43
43
|
)
|
44
44
|
```
|
45
45
|
|
46
|
+
### Chat
|
47
|
+
```ruby
|
48
|
+
client.chat(
|
49
|
+
message: "Hey! How are you?"
|
50
|
+
)
|
51
|
+
```
|
52
|
+
|
46
53
|
### Embed
|
47
54
|
```ruby
|
48
55
|
client.embed(
|
data/lib/cohere/client.rb
CHANGED
@@ -8,10 +8,51 @@ 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)
|
12
12
|
@api_key = api_key
|
13
13
|
end
|
14
14
|
|
15
|
+
def chat(
|
16
|
+
message:,
|
17
|
+
model: nil,
|
18
|
+
stream: false,
|
19
|
+
preamble_override: nil,
|
20
|
+
chat_history: [],
|
21
|
+
conversation_id: nil,
|
22
|
+
prompt_truncation: nil,
|
23
|
+
connectors: [],
|
24
|
+
search_queries_only: false,
|
25
|
+
documents: [],
|
26
|
+
citation_quality: nil,
|
27
|
+
temperature: nil,
|
28
|
+
max_tokens: nil,
|
29
|
+
k: nil,
|
30
|
+
p: nil,
|
31
|
+
frequency_penalty: nil,
|
32
|
+
presence_penalty: nil
|
33
|
+
)
|
34
|
+
response = connection.post("chat") do |req|
|
35
|
+
req.body = {message: message}
|
36
|
+
req.body[:model] = model if model
|
37
|
+
req.body[:stream] = stream if stream
|
38
|
+
req.body[:preamble_override] = preamble_override if preamble_override
|
39
|
+
req.body[:chat_history] = chat_history if chat_history
|
40
|
+
req.body[:conversation_id] = conversation_id if conversation_id
|
41
|
+
req.body[:prompt_truncation] = prompt_truncation if prompt_truncation
|
42
|
+
req.body[:connectors] = connectors if connectors
|
43
|
+
req.body[:search_queries_only] = search_queries_only if search_queries_only
|
44
|
+
req.body[:documents] = documents if documents
|
45
|
+
req.body[:citation_quality] = citation_quality if citation_quality
|
46
|
+
req.body[:temperature] = temperature if temperature
|
47
|
+
req.body[:max_tokens] = max_tokens if max_tokens
|
48
|
+
req.body[:k] = k if k
|
49
|
+
req.body[:p] = p if p
|
50
|
+
req.body[:frequency_penalty] = frequency_penalty if frequency_penalty
|
51
|
+
req.body[:presence_penalty] = presence_penalty if presence_penalty
|
52
|
+
end
|
53
|
+
response.body
|
54
|
+
end
|
55
|
+
|
15
56
|
# This endpoint generates realistic text conditioned on a given input.
|
16
57
|
def generate(
|
17
58
|
prompt:,
|
@@ -53,11 +94,13 @@ module Cohere
|
|
53
94
|
def embed(
|
54
95
|
texts:,
|
55
96
|
model: nil,
|
97
|
+
input_type: nil,
|
56
98
|
truncate: nil
|
57
99
|
)
|
58
100
|
response = connection.post("embed") do |req|
|
59
101
|
req.body = {texts: texts}
|
60
102
|
req.body[:model] = model if model
|
103
|
+
req.body[:input_type] = input_type if input_type
|
61
104
|
req.body[:truncate] = truncate if truncate
|
62
105
|
end
|
63
106
|
response.body
|
data/lib/cohere/version.rb
CHANGED
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.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Bondarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0'
|
72
72
|
requirements: []
|
73
|
-
rubygems_version: 3.
|
73
|
+
rubygems_version: 3.5.3
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: Cohere API client for Ruby.
|