cohere-ai 1.0.2 → 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: 28430515ffef2963f9fa1ae10b23bb3563bdea2e8c8ec7fdb7c711b783249312
4
- data.tar.gz: eb0127adde3a17d90f30bed12a4b61cd27b99b5a4a956329429020d07a3cd658
3
+ metadata.gz: 3ea877fce85c65fa6b22f580d335c1e4d2445f60b85df8db0025cd4e1acb93d6
4
+ data.tar.gz: 435e4efc2cf75f18fd6ed283e915975ffda1561c868bbfd9cc7b691295fa0ea2
5
5
  SHA512:
6
- metadata.gz: a02810e106da158ebaf4b0cbd2aef712d3fc8c29ecb9472a8346cd7e0e905c928f28d698137a0adc57956dfcb0eb7d512767a61c764e7fbee5e82e7f982ab719
7
- data.tar.gz: e1ed417932a6c1be52d1ee733f685d3e676e0d5d6d0c0c2ccfa25ebb0cf576897124be3413650ff4185c62672a461112f285ac35c17fd3595db8c20ef9eed576
6
+ metadata.gz: 74d7b9593bae09f94e6d0c9c60f060a5118f4772be5a8fb8125a0bd96161ba0ac578f8d094a52c9f9312e2fa4c7cb4a35307b078ad7a339bb30309f37a45fae2
7
+ data.tar.gz: e23ee1214c25cf3cde1005a7847dd5a6d752c2e1b3a9e1bb1746ba6c6049c8784a46d8f27c96156c6900f20c91255b01fa5c569779dcb3693650338105b3b717
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
- cohere-ai (1.0.2)
4
+ cohere-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
  cohere-ai!
59
68
  dotenv (~> 2.8, >= 2.8.1)
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 [Cohere AI](https://cohere.com).
9
9
  ## TL;DR and Quick Start
10
10
 
11
11
  ```ruby
12
- gem 'cohere-ai', '~> 1.0.2'
12
+ gem 'cohere-ai', '~> 1.1.0'
13
13
  ```
14
14
 
15
15
  ```ruby
@@ -46,39 +46,40 @@ Result:
46
46
  - [TL;DR and Quick Start](#tldr-and-quick-start)
47
47
  - [Index](#index)
48
48
  - [Setup](#setup)
49
- - [Installing](#installing)
50
- - [Credentials](#credentials)
49
+ - [Installing](#installing)
50
+ - [Credentials](#credentials)
51
51
  - [Usage](#usage)
52
- - [Client](#client)
53
- - [Custom Address](#custom-address)
54
- - [Methods](#methods)
55
- - [chat](#chat)
56
- - [Without Streaming Events](#without-streaming-events)
57
- - [Receiving Stream Events](#receiving-stream-events)
58
- - [generate](#generate)
59
- - [embed](#embed)
60
- - [rerank](#rerank)
61
- - [classify](#classify)
62
- - [detect_language](#detect_language)
63
- - [summarize](#summarize)
64
- - [tokenize](#tokenize)
65
- - [detokenize](#detokenize)
66
- - [Datasets](#datasets)
67
- - [Connectors](#connectors)
68
- - [Streaming and Server-Sent Events (SSE)](#streaming-and-server-sent-events-sse)
69
- - [Server-Sent Events (SSE) Hang](#server-sent-events-sse-hang)
70
- - [Back-and-Forth Conversations](#back-and-forth-conversations)
71
- - [New Functionalities and APIs](#new-functionalities-and-apis)
72
- - [Request Options](#request-options)
73
- - [Timeout](#timeout)
74
- - [Error Handling](#error-handling)
75
- - [Rescuing](#rescuing)
76
- - [For Short](#for-short)
77
- - [Errors](#errors)
52
+ - [Client](#client)
53
+ - [Custom Address](#custom-address)
54
+ - [Methods](#methods)
55
+ - [chat](#chat)
56
+ - [Without Streaming Events](#without-streaming-events)
57
+ - [Receiving Stream Events](#receiving-stream-events)
58
+ - [generate](#generate)
59
+ - [embed](#embed)
60
+ - [rerank](#rerank)
61
+ - [classify](#classify)
62
+ - [detect_language](#detect_language)
63
+ - [summarize](#summarize)
64
+ - [tokenize](#tokenize)
65
+ - [detokenize](#detokenize)
66
+ - [Datasets](#datasets)
67
+ - [Connectors](#connectors)
68
+ - [Streaming and Server-Sent Events (SSE)](#streaming-and-server-sent-events-sse)
69
+ - [Server-Sent Events (SSE) Hang](#server-sent-events-sse-hang)
70
+ - [Back-and-Forth Conversations](#back-and-forth-conversations)
71
+ - [New Functionalities and APIs](#new-functionalities-and-apis)
72
+ - [Request Options](#request-options)
73
+ - [Adapter](#adapter)
74
+ - [Timeout](#timeout)
75
+ - [Error Handling](#error-handling)
76
+ - [Rescuing](#rescuing)
77
+ - [For Short](#for-short)
78
+ - [Errors](#errors)
78
79
  - [Development](#development)
79
- - [Purpose](#purpose)
80
- - [Publish to RubyGems](#publish-to-rubygems)
81
- - [Updating the README](#updating-the-readme)
80
+ - [Purpose](#purpose)
81
+ - [Publish to RubyGems](#publish-to-rubygems)
82
+ - [Updating the README](#updating-the-readme)
82
83
  - [Resources and References](#resources-and-references)
83
84
  - [Disclaimer](#disclaimer)
84
85
 
@@ -87,11 +88,11 @@ Result:
87
88
  ### Installing
88
89
 
89
90
  ```sh
90
- gem install cohere-ai -v 1.0.2
91
+ gem install cohere-ai -v 1.1.0
91
92
  ```
92
93
 
93
94
  ```sh
94
- gem 'cohere-ai', '~> 1.0.2'
95
+ gem 'cohere-ai', '~> 1.1.0'
95
96
  ```
96
97
 
97
98
  ### Credentials
@@ -617,6 +618,21 @@ result = client.request(
617
618
 
618
619
  ### Request Options
619
620
 
621
+ #### Adapter
622
+
623
+ The gem uses [Faraday](https://github.com/lostisland/faraday) with the [Typhoeus](https://github.com/typhoeus/typhoeus) adapter by default.
624
+
625
+ You can use a different adapter if you want:
626
+
627
+ ```ruby
628
+ require 'faraday/net_http'
629
+
630
+ client = Cohere.new(
631
+ credentials: { api_key: ENV['COHERE_API_KEY'] },
632
+ options: { connection: { adapter: :net_http } }
633
+ )
634
+ ```
635
+
620
636
  #### Timeout
621
637
 
622
638
  You can set the maximum number of seconds to wait for the request to complete with the `timeout` option:
@@ -719,7 +735,7 @@ gem build cohere-ai.gemspec
719
735
 
720
736
  gem signin
721
737
 
722
- gem push cohere-ai-1.0.2.gem
738
+ gem push cohere-ai-1.1.0.gem
723
739
  ```
724
740
 
725
741
  ### Updating the README
data/cohere-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
@@ -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 Cohere
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 Cohere
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(payload, server_sent_events: nil, &callback)
@@ -91,6 +96,7 @@ module Cohere
91
96
  partial_json = ''
92
97
 
93
98
  response = Faraday.new(request: @request_options) do |faraday|
99
+ faraday.adapter @faraday_adapter
94
100
  faraday.response :raise_error
95
101
  end.send(method_to_call) do |request|
96
102
  request.url url
data/static/gem.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Cohere
4
4
  GEM = {
5
5
  name: 'cohere-ai',
6
- version: '1.0.2',
6
+ version: '1.1.0',
7
7
  author: 'gbaptista',
8
8
  summary: 'Interact with Cohere AI.',
9
9
  description: 'A Ruby gem for interacting with Cohere AI platform.',
@@ -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 [Cohere AI](https://cohere.com).
9
9
  ## TL;DR and Quick Start
10
10
 
11
11
  ```ruby
12
- gem 'cohere-ai', '~> 1.0.2'
12
+ gem 'cohere-ai', '~> 1.1.0'
13
13
  ```
14
14
 
15
15
  ```ruby
@@ -50,11 +50,11 @@ Result:
50
50
  ### Installing
51
51
 
52
52
  ```sh
53
- gem install cohere-ai -v 1.0.2
53
+ gem install cohere-ai -v 1.1.0
54
54
  ```
55
55
 
56
56
  ```sh
57
- gem 'cohere-ai', '~> 1.0.2'
57
+ gem 'cohere-ai', '~> 1.1.0'
58
58
  ```
59
59
 
60
60
  ### Credentials
@@ -580,6 +580,21 @@ result = client.request(
580
580
 
581
581
  ### Request Options
582
582
 
583
+ #### Adapter
584
+
585
+ The gem uses [Faraday](https://github.com/lostisland/faraday) with the [Typhoeus](https://github.com/typhoeus/typhoeus) adapter by default.
586
+
587
+ You can use a different adapter if you want:
588
+
589
+ ```ruby
590
+ require 'faraday/net_http'
591
+
592
+ client = Cohere.new(
593
+ credentials: { api_key: ENV['COHERE_API_KEY'] },
594
+ options: { connection: { adapter: :net_http } }
595
+ )
596
+ ```
597
+
583
598
  #### Timeout
584
599
 
585
600
  You can set the maximum number of seconds to wait for the request to complete with the `timeout` option:
@@ -682,7 +697,7 @@ gem build cohere-ai.gemspec
682
697
 
683
698
  gem signin
684
699
 
685
- gem push cohere-ai-1.0.2.gem
700
+ gem push cohere-ai-1.1.0.gem
686
701
  ```
687
702
 
688
703
  ### Updating the README
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cohere-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
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 Cohere AI platform.
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/cohere-ai
54
68
  source_code_uri: https://github.com/gbaptista/cohere-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 Cohere AI.
75
89
  test_files: []