mistral-ai 1.1.0 → 1.1.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/.gitignore +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +13 -11
- data/README.md +8 -6
- data/components/errors.rb +0 -1
- data/controllers/client.rb +7 -7
- data/mistral-ai.gemspec +1 -1
- data/static/gem.rb +1 -1
- data/template.md +8 -6
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f4dae097037885f64a62738f8b46a1e0c9c7fa94620d0a8dcd987612bb28dc9
|
4
|
+
data.tar.gz: 81db1da9ab4a4bd7b1ab852b3e34779fb0acaf97f2ba74e99e75dfbd7cc23506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af67f12cd55331fa3d6232c33adccf7e668c6d620694b23e0545025249f7df90c9484a91200bd7b8214f95386ec342f0221529384cc57e82eeada08878f6ba34
|
7
|
+
data.tar.gz: b69f280aa254c345ddc0e475eff4ac21e58e0b4f40cbd291bd96df9dc72df199aa86feddee71504949c8aaa84bd734b314c0f0b93106577267c13e9e930fc4d7
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,28 +1,29 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mistral-ai (1.1.
|
4
|
+
mistral-ai (1.1.2)
|
5
5
|
event_stream_parser (~> 1.0)
|
6
|
-
faraday (~> 2.
|
6
|
+
faraday (~> 2.9)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
ast (2.4.2)
|
12
|
-
base64 (0.2.0)
|
13
12
|
byebug (11.1.3)
|
14
13
|
coderay (1.1.3)
|
14
|
+
dotenv (2.8.1)
|
15
15
|
event_stream_parser (1.0.0)
|
16
|
-
faraday (2.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
faraday-net_http (3.0.2)
|
16
|
+
faraday (2.9.0)
|
17
|
+
faraday-net_http (>= 2.0, < 3.2)
|
18
|
+
faraday-net_http (3.1.0)
|
19
|
+
net-http
|
21
20
|
json (2.7.1)
|
22
21
|
language_server-protocol (3.17.0.3)
|
23
22
|
method_source (1.0.0)
|
23
|
+
net-http (0.4.1)
|
24
|
+
uri
|
24
25
|
parallel (1.24.0)
|
25
|
-
parser (3.
|
26
|
+
parser (3.3.0.3)
|
26
27
|
ast (~> 2.4.1)
|
27
28
|
racc
|
28
29
|
pry (0.14.2)
|
@@ -33,7 +34,7 @@ GEM
|
|
33
34
|
pry (>= 0.13, < 0.15)
|
34
35
|
racc (1.7.3)
|
35
36
|
rainbow (3.1.1)
|
36
|
-
regexp_parser (2.
|
37
|
+
regexp_parser (2.9.0)
|
37
38
|
rexml (3.2.6)
|
38
39
|
rubocop (1.59.0)
|
39
40
|
json (~> 2.3)
|
@@ -49,13 +50,14 @@ GEM
|
|
49
50
|
rubocop-ast (1.30.0)
|
50
51
|
parser (>= 3.2.1.0)
|
51
52
|
ruby-progressbar (1.13.0)
|
52
|
-
ruby2_keywords (0.0.5)
|
53
53
|
unicode-display_width (2.5.0)
|
54
|
+
uri (0.13.0)
|
54
55
|
|
55
56
|
PLATFORMS
|
56
57
|
x86_64-linux
|
57
58
|
|
58
59
|
DEPENDENCIES
|
60
|
+
dotenv (~> 2.8, >= 2.8.1)
|
59
61
|
mistral-ai!
|
60
62
|
pry-byebug (~> 3.10, >= 3.10.1)
|
61
63
|
rubocop (~> 1.58)
|
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.
|
12
|
+
gem 'mistral-ai', '~> 1.1.2'
|
13
13
|
```
|
14
14
|
|
15
15
|
```ruby
|
@@ -85,11 +85,11 @@ Result:
|
|
85
85
|
### Installing
|
86
86
|
|
87
87
|
```sh
|
88
|
-
gem install mistral-ai -v 1.1.
|
88
|
+
gem install mistral-ai -v 1.1.2
|
89
89
|
```
|
90
90
|
|
91
91
|
```sh
|
92
|
-
gem 'mistral-ai', '~> 1.1.
|
92
|
+
gem 'mistral-ai', '~> 1.1.2'
|
93
93
|
```
|
94
94
|
|
95
95
|
### Credentials
|
@@ -410,7 +410,8 @@ Mistral may launch a new endpoint that we haven't covered in the Gem yet. If tha
|
|
410
410
|
result = client.request(
|
411
411
|
'v1/chat/completions',
|
412
412
|
{ model: 'mistral-medium',
|
413
|
-
messages: [{ role: 'user', content: 'hi!' }] }
|
413
|
+
messages: [{ role: 'user', content: 'hi!' }] },
|
414
|
+
request_method: 'POST', server_sent_events: true
|
414
415
|
)
|
415
416
|
```
|
416
417
|
|
@@ -494,7 +495,6 @@ MistralError
|
|
494
495
|
|
495
496
|
MissingAPIKeyError
|
496
497
|
BlockWithoutServerSentEventsError
|
497
|
-
UnsupportedError
|
498
498
|
|
499
499
|
RequestError
|
500
500
|
```
|
@@ -504,6 +504,8 @@ RequestError
|
|
504
504
|
```bash
|
505
505
|
bundle
|
506
506
|
rubocop -A
|
507
|
+
|
508
|
+
bundle exec ruby spec/tasks/run-client.rb
|
507
509
|
```
|
508
510
|
|
509
511
|
### Purpose
|
@@ -517,7 +519,7 @@ gem build mistral-ai.gemspec
|
|
517
519
|
|
518
520
|
gem signin
|
519
521
|
|
520
|
-
gem push mistral-ai-1.1.
|
522
|
+
gem push mistral-ai-1.1.2.gem
|
521
523
|
```
|
522
524
|
|
523
525
|
### Updating the README
|
data/components/errors.rb
CHANGED
data/controllers/client.rb
CHANGED
@@ -4,7 +4,7 @@ require 'event_stream_parser'
|
|
4
4
|
require 'faraday'
|
5
5
|
require 'json'
|
6
6
|
|
7
|
-
require_relative '../
|
7
|
+
require_relative '../components/errors'
|
8
8
|
|
9
9
|
module Mistral
|
10
10
|
module Controllers
|
@@ -24,7 +24,7 @@ module Mistral
|
|
24
24
|
end
|
25
25
|
|
26
26
|
if @api_key.nil? && @address == "#{DEFAULT_ADDRESS}/"
|
27
|
-
raise MissingAPIKeyError, 'Missing API Key, which is required.'
|
27
|
+
raise Errors::MissingAPIKeyError, 'Missing API Key, which is required.'
|
28
28
|
end
|
29
29
|
|
30
30
|
@request_options = config.dig(:options, :connection, :request)
|
@@ -51,18 +51,18 @@ module Mistral
|
|
51
51
|
request('v1/models', nil, server_sent_events: false, request_method: 'GET', &callback)
|
52
52
|
end
|
53
53
|
|
54
|
-
def request(path, payload, server_sent_events: nil, request_method: 'POST', &callback)
|
54
|
+
def request(path, payload = nil, server_sent_events: nil, request_method: 'POST', &callback)
|
55
55
|
server_sent_events_enabled = server_sent_events.nil? ? @server_sent_events : server_sent_events
|
56
56
|
url = "#{@address}#{path}"
|
57
57
|
|
58
58
|
if !callback.nil? && !server_sent_events_enabled
|
59
|
-
raise BlockWithoutServerSentEventsError,
|
59
|
+
raise Errors::BlockWithoutServerSentEventsError,
|
60
60
|
'You are trying to use a block without Server Sent Events (SSE) enabled.'
|
61
61
|
end
|
62
62
|
|
63
63
|
results = []
|
64
64
|
|
65
|
-
method_to_call = request_method
|
65
|
+
method_to_call = request_method.to_s.strip.downcase.to_sym
|
66
66
|
|
67
67
|
response = Faraday.new(request: @request_options) do |faraday|
|
68
68
|
faraday.response :raise_error
|
@@ -110,11 +110,11 @@ module Mistral
|
|
110
110
|
|
111
111
|
results.map { |result| result[:event] }
|
112
112
|
rescue Faraday::ServerError => e
|
113
|
-
raise RequestError.new(e.message, request: e, payload:)
|
113
|
+
raise Errors::RequestError.new(e.message, request: e, payload:)
|
114
114
|
end
|
115
115
|
|
116
116
|
def safe_parse_json(raw)
|
117
|
-
raw.start_with?('{', '[') ? JSON.parse(raw) : raw
|
117
|
+
raw.to_s.lstrip.start_with?('{', '[') ? JSON.parse(raw) : raw
|
118
118
|
rescue JSON::ParserError
|
119
119
|
raw
|
120
120
|
end
|
data/mistral-ai.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.require_paths = ['ports/dsl']
|
31
31
|
|
32
32
|
spec.add_dependency 'event_stream_parser', '~> 1.0'
|
33
|
-
spec.add_dependency 'faraday', '~> 2.
|
33
|
+
spec.add_dependency 'faraday', '~> 2.9'
|
34
34
|
|
35
35
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
36
36
|
end
|
data/static/gem.rb
CHANGED
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.
|
12
|
+
gem 'mistral-ai', '~> 1.1.2'
|
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.
|
58
|
+
gem install mistral-ai -v 1.1.2
|
59
59
|
```
|
60
60
|
|
61
61
|
```sh
|
62
|
-
gem 'mistral-ai', '~> 1.1.
|
62
|
+
gem 'mistral-ai', '~> 1.1.2'
|
63
63
|
```
|
64
64
|
|
65
65
|
### Credentials
|
@@ -380,7 +380,8 @@ Mistral may launch a new endpoint that we haven't covered in the Gem yet. If tha
|
|
380
380
|
result = client.request(
|
381
381
|
'v1/chat/completions',
|
382
382
|
{ model: 'mistral-medium',
|
383
|
-
messages: [{ role: 'user', content: 'hi!' }] }
|
383
|
+
messages: [{ role: 'user', content: 'hi!' }] },
|
384
|
+
request_method: 'POST', server_sent_events: true
|
384
385
|
)
|
385
386
|
```
|
386
387
|
|
@@ -464,7 +465,6 @@ MistralError
|
|
464
465
|
|
465
466
|
MissingAPIKeyError
|
466
467
|
BlockWithoutServerSentEventsError
|
467
|
-
UnsupportedError
|
468
468
|
|
469
469
|
RequestError
|
470
470
|
```
|
@@ -474,6 +474,8 @@ RequestError
|
|
474
474
|
```bash
|
475
475
|
bundle
|
476
476
|
rubocop -A
|
477
|
+
|
478
|
+
bundle exec ruby spec/tasks/run-client.rb
|
477
479
|
```
|
478
480
|
|
479
481
|
### Purpose
|
@@ -487,7 +489,7 @@ gem build mistral-ai.gemspec
|
|
487
489
|
|
488
490
|
gem signin
|
489
491
|
|
490
|
-
gem push mistral-ai-1.1.
|
492
|
+
gem push mistral-ai-1.1.2.gem
|
491
493
|
```
|
492
494
|
|
493
495
|
### 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.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gbaptista
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: event_stream_parser
|
@@ -30,20 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '2.
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 2.8.1
|
33
|
+
version: '2.9'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '2.
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 2.8.1
|
40
|
+
version: '2.9'
|
47
41
|
description: A Ruby gem for interacting with Mistral AI's large language models.
|
48
42
|
email:
|
49
43
|
executables: []
|
@@ -88,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
82
|
- !ruby/object:Gem::Version
|
89
83
|
version: '0'
|
90
84
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
85
|
+
rubygems_version: 3.3.3
|
92
86
|
signing_key:
|
93
87
|
specification_version: 4
|
94
88
|
summary: Interact with Mistral AI.
|