mistral-ai 1.1.2 → 1.2.0
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/Gemfile +1 -1
- data/Gemfile.lock +14 -5
- data/README.md +44 -28
- data/controllers/client.rb +6 -0
- data/mistral-ai.gemspec +1 -0
- data/static/gem.rb +1 -1
- data/tasks/generate-readme.clj +1 -1
- data/template.md +19 -4
- metadata +20 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ffe32ff356fd57cc72164264b4773492605133be8e3b673b8ceaf371d0cd0858
|
|
4
|
+
data.tar.gz: 5e986c0972820f5e1be8eb510210c9555ea94ea81986cbecd1295e33cc3a7fb1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 414756c816683899bf265642011f0f2598cc5fc57b1011bad67cc480f9bdd779f5ed965a76c00a1f83352699ff0e9c8b8a266fd3bc4804eccbe36ea2c396487f
|
|
7
|
+
data.tar.gz: 45664c86d3a7ea5cac7a10ed8d9b9c3be5f9770da27613816b7a4990ad3902aaa092e7ce02e07f01e21c789c5a09b172c34150f8c210335526b83e95b2df59a5
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
mistral-ai (1.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
55
|
-
|
|
54
|
+
- [Installing](#installing)
|
|
55
|
+
- [Credentials](#credentials)
|
|
56
56
|
- [Usage](#usage)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
- [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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.
|
|
89
|
+
gem install mistral-ai -v 1.2.0
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
```sh
|
|
92
|
-
gem 'mistral-ai', '~> 1.
|
|
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.
|
|
538
|
+
gem push mistral-ai-1.2.0.gem
|
|
523
539
|
```
|
|
524
540
|
|
|
525
541
|
### Updating the README
|
data/controllers/client.rb
CHANGED
|
@@ -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
data/static/gem.rb
CHANGED
data/tasks/generate-readme.clj
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.
|
|
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.
|
|
58
|
+
gem install mistral-ai -v 1.2.0
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
```sh
|
|
62
|
-
gem 'mistral-ai', '~> 1.
|
|
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.
|
|
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.
|
|
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-
|
|
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: []
|