mistral-ai 1.1.2 → 1.2.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: 2f4dae097037885f64a62738f8b46a1e0c9c7fa94620d0a8dcd987612bb28dc9
4
- data.tar.gz: 81db1da9ab4a4bd7b1ab852b3e34779fb0acaf97f2ba74e99e75dfbd7cc23506
3
+ metadata.gz: ffe32ff356fd57cc72164264b4773492605133be8e3b673b8ceaf371d0cd0858
4
+ data.tar.gz: 5e986c0972820f5e1be8eb510210c9555ea94ea81986cbecd1295e33cc3a7fb1
5
5
  SHA512:
6
- metadata.gz: af67f12cd55331fa3d6232c33adccf7e668c6d620694b23e0545025249f7df90c9484a91200bd7b8214f95386ec342f0221529384cc57e82eeada08878f6ba34
7
- data.tar.gz: b69f280aa254c345ddc0e475eff4ac21e58e0b4f40cbd291bd96df9dc72df199aa86feddee71504949c8aaa84bd734b314c0f0b93106577267c13e9e930fc4d7
6
+ metadata.gz: 414756c816683899bf265642011f0f2598cc5fc57b1011bad67cc480f9bdd779f5ed965a76c00a1f83352699ff0e9c8b8a266fd3bc4804eccbe36ea2c396487f
7
+ data.tar.gz: 45664c86d3a7ea5cac7a10ed8d9b9c3be5f9770da27613816b7a4990ad3902aaa092e7ce02e07f01e21c789c5a09b172c34150f8c210335526b83e95b2df59a5
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,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mistral-ai (1.1.2)
4
+ mistral-ai (1.2.0)
5
5
  event_stream_parser (~> 1.0)
6
6
  faraday (~> 2.9)
7
+ faraday-typhoeus (~> 1.1)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
@@ -12,18 +13,24 @@ GEM
12
13
  byebug (11.1.3)
13
14
  coderay (1.1.3)
14
15
  dotenv (2.8.1)
16
+ ethon (0.16.0)
17
+ ffi (>= 1.15.0)
15
18
  event_stream_parser (1.0.0)
16
19
  faraday (2.9.0)
17
20
  faraday-net_http (>= 2.0, < 3.2)
18
21
  faraday-net_http (3.1.0)
19
22
  net-http
23
+ faraday-typhoeus (1.1.0)
24
+ faraday (~> 2.0)
25
+ typhoeus (~> 1.4)
26
+ ffi (1.16.3)
20
27
  json (2.7.1)
21
28
  language_server-protocol (3.17.0.3)
22
29
  method_source (1.0.0)
23
30
  net-http (0.4.1)
24
31
  uri
25
32
  parallel (1.24.0)
26
- parser (3.3.0.3)
33
+ parser (3.3.0.5)
27
34
  ast (~> 2.4.1)
28
35
  racc
29
36
  pry (0.14.2)
@@ -36,11 +43,11 @@ GEM
36
43
  rainbow (3.1.1)
37
44
  regexp_parser (2.9.0)
38
45
  rexml (3.2.6)
39
- rubocop (1.59.0)
46
+ rubocop (1.60.2)
40
47
  json (~> 2.3)
41
48
  language_server-protocol (>= 3.17.0)
42
49
  parallel (~> 1.10)
43
- parser (>= 3.2.2.4)
50
+ parser (>= 3.3.0.2)
44
51
  rainbow (>= 2.2.2, < 4.0)
45
52
  regexp_parser (>= 1.8, < 3.0)
46
53
  rexml (>= 3.2.5, < 4.0)
@@ -50,6 +57,8 @@ GEM
50
57
  rubocop-ast (1.30.0)
51
58
  parser (>= 3.2.1.0)
52
59
  ruby-progressbar (1.13.0)
60
+ typhoeus (1.4.1)
61
+ ethon (>= 0.9.0)
53
62
  unicode-display_width (2.5.0)
54
63
  uri (0.13.0)
55
64
 
@@ -60,7 +69,7 @@ DEPENDENCIES
60
69
  dotenv (~> 2.8, >= 2.8.1)
61
70
  mistral-ai!
62
71
  pry-byebug (~> 3.10, >= 3.10.1)
63
- rubocop (~> 1.58)
72
+ rubocop (~> 1.60, >= 1.60.2)
64
73
 
65
74
  BUNDLED WITH
66
75
  2.4.22
data/README.md CHANGED
@@ -9,7 +9,7 @@ A Ruby gem for interacting with [Mistral AI](https://mistral.ai)'s large languag
9
9
  ## TL;DR and Quick Start
10
10
 
11
11
  ```ruby
12
- gem 'mistral-ai', '~> 1.1.2'
12
+ gem 'mistral-ai', '~> 1.2.0'
13
13
  ```
14
14
 
15
15
  ```ruby
@@ -51,32 +51,33 @@ Result:
51
51
  - [TL;DR and Quick Start](#tldr-and-quick-start)
52
52
  - [Index](#index)
53
53
  - [Setup](#setup)
54
- - [Installing](#installing)
55
- - [Credentials](#credentials)
54
+ - [Installing](#installing)
55
+ - [Credentials](#credentials)
56
56
  - [Usage](#usage)
57
- - [Client](#client)
58
- - [Custom Address](#custom-address)
59
- - [Methods](#methods)
60
- - [chat_completions](#chat_completions)
61
- - [Without Streaming Events](#without-streaming-events)
62
- - [Receiving Stream Events](#receiving-stream-events)
63
- - [embeddings](#embeddings)
64
- - [models](#models)
65
- - [Streaming and Server-Sent Events (SSE)](#streaming-and-server-sent-events-sse)
66
- - [Server-Sent Events (SSE) Hang](#server-sent-events-sse-hang)
67
- - [System Messages](#system-messages)
68
- - [Back-and-Forth Conversations](#back-and-forth-conversations)
69
- - [New Functionalities and APIs](#new-functionalities-and-apis)
70
- - [Request Options](#request-options)
71
- - [Timeout](#timeout)
72
- - [Error Handling](#error-handling)
73
- - [Rescuing](#rescuing)
74
- - [For Short](#for-short)
75
- - [Errors](#errors)
57
+ - [Client](#client)
58
+ - [Custom Address](#custom-address)
59
+ - [Methods](#methods)
60
+ - [chat_completions](#chat_completions)
61
+ - [Without Streaming Events](#without-streaming-events)
62
+ - [Receiving Stream Events](#receiving-stream-events)
63
+ - [embeddings](#embeddings)
64
+ - [models](#models)
65
+ - [Streaming and Server-Sent Events (SSE)](#streaming-and-server-sent-events-sse)
66
+ - [Server-Sent Events (SSE) Hang](#server-sent-events-sse-hang)
67
+ - [System Messages](#system-messages)
68
+ - [Back-and-Forth Conversations](#back-and-forth-conversations)
69
+ - [New Functionalities and APIs](#new-functionalities-and-apis)
70
+ - [Request Options](#request-options)
71
+ - [Adapter](#adapter)
72
+ - [Timeout](#timeout)
73
+ - [Error Handling](#error-handling)
74
+ - [Rescuing](#rescuing)
75
+ - [For Short](#for-short)
76
+ - [Errors](#errors)
76
77
  - [Development](#development)
77
- - [Purpose](#purpose)
78
- - [Publish to RubyGems](#publish-to-rubygems)
79
- - [Updating the README](#updating-the-readme)
78
+ - [Purpose](#purpose)
79
+ - [Publish to RubyGems](#publish-to-rubygems)
80
+ - [Updating the README](#updating-the-readme)
80
81
  - [Resources and References](#resources-and-references)
81
82
  - [Disclaimer](#disclaimer)
82
83
 
@@ -85,11 +86,11 @@ Result:
85
86
  ### Installing
86
87
 
87
88
  ```sh
88
- gem install mistral-ai -v 1.1.2
89
+ gem install mistral-ai -v 1.2.0
89
90
  ```
90
91
 
91
92
  ```sh
92
- gem 'mistral-ai', '~> 1.1.2'
93
+ gem 'mistral-ai', '~> 1.2.0'
93
94
  ```
94
95
 
95
96
  ### Credentials
@@ -417,6 +418,21 @@ result = client.request(
417
418
 
418
419
  ### Request Options
419
420
 
421
+ #### Adapter
422
+
423
+ The gem uses [Faraday](https://github.com/lostisland/faraday) with the [Typhoeus](https://github.com/typhoeus/typhoeus) adapter by default.
424
+
425
+ You can use a different adapter if you want:
426
+
427
+ ```ruby
428
+ require 'faraday/net_http'
429
+
430
+ client = Mistral.new(
431
+ credentials: { api_key: ENV['MISTRAL_API_KEY'] },
432
+ options: { connection: { adapter: :net_http } }
433
+ )
434
+ ```
435
+
420
436
  #### Timeout
421
437
 
422
438
  You can set the maximum number of seconds to wait for the request to complete with the `timeout` option:
@@ -519,7 +535,7 @@ gem build mistral-ai.gemspec
519
535
 
520
536
  gem signin
521
537
 
522
- gem push mistral-ai-1.1.2.gem
538
+ gem push mistral-ai-1.2.0.gem
523
539
  ```
524
540
 
525
541
  ### Updating the README
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'event_stream_parser'
4
4
  require 'faraday'
5
+ require 'faraday/typhoeus'
5
6
  require 'json'
6
7
 
7
8
  require_relative '../components/errors'
@@ -13,6 +14,8 @@ module Mistral
13
14
 
14
15
  ALLOWED_REQUEST_OPTIONS = %i[timeout open_timeout read_timeout write_timeout].freeze
15
16
 
17
+ DEFAULT_FARADAY_ADAPTER = :typhoeus
18
+
16
19
  def initialize(config)
17
20
  @api_key = config.dig(:credentials, :api_key)
18
21
  @server_sent_events = config.dig(:options, :server_sent_events)
@@ -36,6 +39,8 @@ module Mistral
36
39
  else
37
40
  {}
38
41
  end
42
+
43
+ @faraday_adapter = config.dig(:options, :connection, :adapter) || DEFAULT_FARADAY_ADAPTER
39
44
  end
40
45
 
41
46
  def chat_completions(payload, server_sent_events: nil, &callback)
@@ -65,6 +70,7 @@ module Mistral
65
70
  method_to_call = request_method.to_s.strip.downcase.to_sym
66
71
 
67
72
  response = Faraday.new(request: @request_options) do |faraday|
73
+ faraday.adapter @faraday_adapter
68
74
  faraday.response :raise_error
69
75
  end.send(method_to_call) do |request|
70
76
  request.url url
data/mistral-ai.gemspec CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_dependency 'event_stream_parser', '~> 1.0'
33
33
  spec.add_dependency 'faraday', '~> 2.9'
34
+ spec.add_dependency 'faraday-typhoeus', '~> 1.1'
34
35
 
35
36
  spec.metadata['rubygems_mfa_required'] = 'true'
36
37
  end
data/static/gem.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Mistral
4
4
  GEM = {
5
5
  name: 'mistral-ai',
6
- version: '1.1.2',
6
+ version: '1.2.0',
7
7
  author: 'gbaptista',
8
8
  summary: 'Interact with Mistral AI.',
9
9
  description: "A Ruby gem for interacting with Mistral AI's large language models.",
@@ -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 [Mistral AI](https://mistral.ai)'s large languag
9
9
  ## TL;DR and Quick Start
10
10
 
11
11
  ```ruby
12
- gem 'mistral-ai', '~> 1.1.2'
12
+ gem 'mistral-ai', '~> 1.2.0'
13
13
  ```
14
14
 
15
15
  ```ruby
@@ -55,11 +55,11 @@ Result:
55
55
  ### Installing
56
56
 
57
57
  ```sh
58
- gem install mistral-ai -v 1.1.2
58
+ gem install mistral-ai -v 1.2.0
59
59
  ```
60
60
 
61
61
  ```sh
62
- gem 'mistral-ai', '~> 1.1.2'
62
+ gem 'mistral-ai', '~> 1.2.0'
63
63
  ```
64
64
 
65
65
  ### Credentials
@@ -387,6 +387,21 @@ result = client.request(
387
387
 
388
388
  ### Request Options
389
389
 
390
+ #### Adapter
391
+
392
+ The gem uses [Faraday](https://github.com/lostisland/faraday) with the [Typhoeus](https://github.com/typhoeus/typhoeus) adapter by default.
393
+
394
+ You can use a different adapter if you want:
395
+
396
+ ```ruby
397
+ require 'faraday/net_http'
398
+
399
+ client = Mistral.new(
400
+ credentials: { api_key: ENV['MISTRAL_API_KEY'] },
401
+ options: { connection: { adapter: :net_http } }
402
+ )
403
+ ```
404
+
390
405
  #### Timeout
391
406
 
392
407
  You can set the maximum number of seconds to wait for the request to complete with the `timeout` option:
@@ -489,7 +504,7 @@ gem build mistral-ai.gemspec
489
504
 
490
505
  gem signin
491
506
 
492
- gem push mistral-ai-1.1.2.gem
507
+ gem push mistral-ai-1.2.0.gem
493
508
  ```
494
509
 
495
510
  ### Updating the README
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mistral-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.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: event_stream_parser
@@ -38,8 +38,22 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday-typhoeus
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
41
55
  description: A Ruby gem for interacting with Mistral AI's large language models.
42
- email:
56
+ email:
43
57
  executables: []
44
58
  extensions: []
45
59
  extra_rdoc_files: []
@@ -67,7 +81,7 @@ metadata:
67
81
  homepage_uri: https://github.com/gbaptista/mistral-ai
68
82
  source_code_uri: https://github.com/gbaptista/mistral-ai
69
83
  rubygems_mfa_required: 'true'
70
- post_install_message:
84
+ post_install_message:
71
85
  rdoc_options: []
72
86
  require_paths:
73
87
  - ports/dsl
@@ -83,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
97
  version: '0'
84
98
  requirements: []
85
99
  rubygems_version: 3.3.3
86
- signing_key:
100
+ signing_key:
87
101
  specification_version: 4
88
102
  summary: Interact with Mistral AI.
89
103
  test_files: []