mistral-ai 1.0.0 → 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: 19bfd295de85b2f506daf1623bddc5966c34a0844b823fef2b30fd9de46f0dc9
4
- data.tar.gz: b1bdd0da891f5280da914601a32ec351a4a848791d5f67c3304ab9ca96f87b1c
3
+ metadata.gz: a5a4440552277c82714d8e396bd842688a82bdc0d620d71a2783e51111e122ea
4
+ data.tar.gz: 1bcd20702986e71433cfeb3bb61970af0bc87da6a2274d1b89dd85c8f118dff0
5
5
  SHA512:
6
- metadata.gz: e7ec9676abe38edca924552c4bc010cb1e04e91406f0cf1c28000dd69f76ebad53567bb48fe18977e1ead0751772d75af537fa5541bd5cf4affb8a7671a8f9fe
7
- data.tar.gz: 0ca1dd38cba7bff0cd21934a0a9626ab97ff74cac5fef2fa572f7a1e87aafc8bc5191ba3a919535e7f87b8508ab7083c80cc037b7a6adb39be43fb66f8789a5c
6
+ metadata.gz: efed3e028c80c4cbd0f694c5b739637fcf6277b71c95549f2cde0e3d278b09224e267d29098091cecfad8b792411f8f38edae48000f379a4b2fc2e88aef9fffc
7
+ data.tar.gz: d6d92ec1ed4dac56c90367d0e499d5f0b3be992bef29291502dc470d8b9c12274c19331062fe6ad22898c1ece0261bbf2c392c9416dd5520058575f2675c6ff6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mistral-ai (1.0.0)
4
+ mistral-ai (1.1.0)
5
5
  event_stream_parser (~> 1.0)
6
6
  faraday (~> 2.8, >= 2.8.1)
7
7
 
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.0.0'
12
+ gem 'mistral-ai', '~> 1.1.0'
13
13
  ```
14
14
 
15
15
  ```ruby
@@ -61,6 +61,7 @@ Result:
61
61
  - [Without Streaming Events](#without-streaming-events)
62
62
  - [Receiving Stream Events](#receiving-stream-events)
63
63
  - [embeddings](#embeddings)
64
+ - [models](#models)
64
65
  - [Streaming and Server-Sent Events (SSE)](#streaming-and-server-sent-events-sse)
65
66
  - [Server-Sent Events (SSE) Hang](#server-sent-events-sse-hang)
66
67
  - [System Messages](#system-messages)
@@ -84,11 +85,11 @@ Result:
84
85
  ### Installing
85
86
 
86
87
  ```sh
87
- gem install mistral-ai -v 1.0.0
88
+ gem install mistral-ai -v 1.1.0
88
89
  ```
89
90
 
90
91
  ```sh
91
- gem 'mistral-ai', '~> 1.0.0'
92
+ gem 'mistral-ai', '~> 1.1.0'
92
93
  ```
93
94
 
94
95
  ### Credentials
@@ -270,6 +271,45 @@ Result:
270
271
 
271
272
  ```
272
273
 
274
+ #### models
275
+
276
+ ```ruby
277
+ result = client.models
278
+ ```
279
+
280
+ Result:
281
+ ```ruby
282
+ { 'object' => 'list',
283
+ 'data' =>
284
+ [{ 'id' => 'mistral-medium',
285
+ 'object' => 'model',
286
+ 'created' => 1_703_855_983,
287
+ 'owned_by' => 'mistralai',
288
+ 'root' => nil,
289
+ 'parent' => nil,
290
+ 'permission' =>
291
+ [{ 'id' => 'modelperm-30...',
292
+ 'object' => 'model_permission',
293
+ 'created' => 1_703_855_983,
294
+ 'allow_create_engine' => false,
295
+ 'allow_sampling' => true,
296
+ 'allow_logprobs' => false,
297
+ 'allow_search_indices' => false,
298
+ 'allow_view' => true,
299
+ 'allow_fine_tuning' => false,
300
+ 'organization' => '*',
301
+ 'group' => nil,
302
+ 'is_blocking' => false }] },
303
+ { 'id' => 'mistral-small',
304
+ 'object' => 'model',
305
+ 'created' => 1_703_855_983,
306
+ 'owned_by' => 'mistralai',
307
+ # ...
308
+ },
309
+ # ...
310
+ ] }
311
+ ```
312
+
273
313
  ### Streaming and Server-Sent Events (SSE)
274
314
 
275
315
  [Server-Sent Events (SSE)](https://en.wikipedia.org/wiki/Server-sent_events) is a technology that allows certain endpoints to offer streaming capabilities, such as creating the impression that "the model is typing along with you," rather than delivering the entire answer all at once.
@@ -477,7 +517,7 @@ gem build mistral-ai.gemspec
477
517
 
478
518
  gem signin
479
519
 
480
- gem push mistral-ai-1.0.0.gem
520
+ gem push mistral-ai-1.1.0.gem
481
521
  ```
482
522
 
483
523
  ### Updating the README
@@ -43,13 +43,17 @@ module Mistral
43
43
  request('v1/chat/completions', payload, server_sent_events:, &callback)
44
44
  end
45
45
 
46
- def embeddings(payload, server_sent_events: nil, &callback)
46
+ def embeddings(payload, _server_sent_events: nil, &callback)
47
47
  request('v1/embeddings', payload, server_sent_events: false, &callback)
48
48
  end
49
49
 
50
- def request(path, payload, server_sent_events: nil, &callback)
50
+ def models(_server_sent_events: nil, &callback)
51
+ request('v1/models', nil, server_sent_events: false, request_method: 'GET', &callback)
52
+ end
53
+
54
+ def request(path, payload, server_sent_events: nil, request_method: 'POST', &callback)
51
55
  server_sent_events_enabled = server_sent_events.nil? ? @server_sent_events : server_sent_events
52
- url = "#{@address}/#{path}"
56
+ url = "#{@address}#{path}"
53
57
 
54
58
  if !callback.nil? && !server_sent_events_enabled
55
59
  raise BlockWithoutServerSentEventsError,
@@ -58,15 +62,17 @@ module Mistral
58
62
 
59
63
  results = []
60
64
 
65
+ method_to_call = request_method == 'POST' ? :post : :get
66
+
61
67
  response = Faraday.new(request: @request_options) do |faraday|
62
68
  faraday.response :raise_error
63
- end.post do |request|
69
+ end.send(method_to_call) do |request|
64
70
  request.url url
65
71
  request.headers['Content-Type'] = 'application/json'
66
72
 
67
73
  request.headers['Authorization'] = "Bearer #{@api_key}" unless @api_key.nil?
68
74
 
69
- request.body = payload.to_json
75
+ request.body = payload.to_json unless payload.nil?
70
76
 
71
77
  if server_sent_events_enabled
72
78
  parser = EventStreamParser::Parser.new
data/static/gem.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Mistral
4
4
  GEM = {
5
5
  name: 'mistral-ai',
6
- version: '1.0.0',
6
+ version: '1.1.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.",
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.0.0'
12
+ gem 'mistral-ai', '~> 1.1.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.0.0
58
+ gem install mistral-ai -v 1.1.0
59
59
  ```
60
60
 
61
61
  ```sh
62
- gem 'mistral-ai', '~> 1.0.0'
62
+ gem 'mistral-ai', '~> 1.1.0'
63
63
  ```
64
64
 
65
65
  ### Credentials
@@ -241,6 +241,45 @@ Result:
241
241
 
242
242
  ```
243
243
 
244
+ #### models
245
+
246
+ ```ruby
247
+ result = client.models
248
+ ```
249
+
250
+ Result:
251
+ ```ruby
252
+ { 'object' => 'list',
253
+ 'data' =>
254
+ [{ 'id' => 'mistral-medium',
255
+ 'object' => 'model',
256
+ 'created' => 1_703_855_983,
257
+ 'owned_by' => 'mistralai',
258
+ 'root' => nil,
259
+ 'parent' => nil,
260
+ 'permission' =>
261
+ [{ 'id' => 'modelperm-30...',
262
+ 'object' => 'model_permission',
263
+ 'created' => 1_703_855_983,
264
+ 'allow_create_engine' => false,
265
+ 'allow_sampling' => true,
266
+ 'allow_logprobs' => false,
267
+ 'allow_search_indices' => false,
268
+ 'allow_view' => true,
269
+ 'allow_fine_tuning' => false,
270
+ 'organization' => '*',
271
+ 'group' => nil,
272
+ 'is_blocking' => false }] },
273
+ { 'id' => 'mistral-small',
274
+ 'object' => 'model',
275
+ 'created' => 1_703_855_983,
276
+ 'owned_by' => 'mistralai',
277
+ # ...
278
+ },
279
+ # ...
280
+ ] }
281
+ ```
282
+
244
283
  ### Streaming and Server-Sent Events (SSE)
245
284
 
246
285
  [Server-Sent Events (SSE)](https://en.wikipedia.org/wiki/Server-sent_events) is a technology that allows certain endpoints to offer streaming capabilities, such as creating the impression that "the model is typing along with you," rather than delivering the entire answer all at once.
@@ -448,7 +487,7 @@ gem build mistral-ai.gemspec
448
487
 
449
488
  gem signin
450
489
 
451
- gem push mistral-ai-1.0.0.gem
490
+ gem push mistral-ai-1.1.0.gem
452
491
  ```
453
492
 
454
493
  ### 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.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gbaptista
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-28 00:00:00.000000000 Z
11
+ date: 2023-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: event_stream_parser