omniai-mistral 1.6.2 → 1.7.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: 06a0ef7934fc23948925d5c35b75898df7148f162564db8a59fffa9106efa8d8
4
- data.tar.gz: 22edea50f3d9a71b3ef659fd731078730adec47cc46190208fe30022a37a9d2e
3
+ metadata.gz: d6fdad55d7cfc5b9d1845a8ec2d64772e2af5cc3d74d31b3d746732bc7509b15
4
+ data.tar.gz: d31338fb81948d32cb0937a5d206bd9393a92c4fb43523477a1508941e7f2c09
5
5
  SHA512:
6
- metadata.gz: 506d07b0b05993c88c540778d3116f608dc3740726e6f0453a72ac444c8b9139c2020476fc3c1627f581a8fcb83e4c11113048b58feda99381f6480b56f1eaed
7
- data.tar.gz: 0e8dae928a6d2d64ac459ce48d370bc866516f133fc8e60d14a581deb62ff6761cb3480a294ee8c5afb95a675d9ebc0e4887ec5683f8a80872f9bb8afcfd8447
6
+ metadata.gz: 2282359b0e6fcd610c1d73b7b9a236371196014458aea74585231de83a3697194879d3917b9f64b8ed5c7fabaab3a9a5f1405b849a5e891e55f7308a8143f2b4
7
+ data.tar.gz: 5358665adf78efed8c92f9e52f3b2854cd23fe6f82598c2639b25b707252906c798bf46250e6f6ec7d1b2c6d39822439497216063f6e398f22470d16c5c088e9
data/README.md CHANGED
@@ -103,3 +103,12 @@ JSON.parse(completion.choice.message.content) # { "name": "Ringo" }
103
103
  [Mistral API Reference `response_format`](https://docs.mistral.ai/api/)
104
104
 
105
105
  > When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message.
106
+
107
+ ### Embed
108
+
109
+ Text can be converted into a vector embedding for similarity comparison usage via:
110
+
111
+ ```ruby
112
+ response = client.embed('The quick brown fox jumps over a lazy dog.')
113
+ response.embedding # [0.0, ...]
114
+ ```
@@ -58,6 +58,14 @@ module OmniAI
58
58
  def chat(messages = nil, model: Chat::DEFAULT_MODEL, temperature: nil, format: nil, stream: nil, tools: nil, &)
59
59
  Chat.process!(messages, model:, temperature:, format:, stream:, tools:, client: self, &)
60
60
  end
61
+
62
+ # @raise [OmniAI::Error]
63
+ #
64
+ # @param input [String, Array<String>, Array<Integer>] required
65
+ # @param model [String] optional
66
+ def embed(input, model: Embed::DEFAULT_MODEL)
67
+ Embed.process!(input, model:, client: self)
68
+ end
61
69
  end
62
70
  end
63
71
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAI
4
+ module Mistral
5
+ # An Mistral embed implementation.
6
+ #
7
+ # Usage:
8
+ #
9
+ # input = "..."
10
+ # response = OmniAI::Mistral::Embed.process!(input, client: client)
11
+ # response.embedding [0.0, ...]
12
+ class Embed < OmniAI::Embed
13
+ module Model
14
+ EMBED = 'mistral-embed'
15
+ end
16
+
17
+ DEFAULT_MODEL = Model::EMBED
18
+
19
+ protected
20
+
21
+ # @return [Hash]
22
+ def payload
23
+ { model: @model, input: arrayify(@input) }
24
+ end
25
+
26
+ # @return [String]
27
+ def path
28
+ "/#{OmniAI::Mistral::Client::VERSION}/embeddings"
29
+ end
30
+
31
+ # @param [Object] value
32
+ # @return [Array]
33
+ def arrayify(value)
34
+ value.is_a?(Array) ? value : [value]
35
+ end
36
+ end
37
+ end
38
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Mistral
5
- VERSION = '1.6.2'
5
+ VERSION = '1.7.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai-mistral
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-18 00:00:00.000000000 Z
11
+ date: 2024-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: event_stream_parser
@@ -65,6 +65,7 @@ files:
65
65
  - lib/omniai/mistral/chat.rb
66
66
  - lib/omniai/mistral/client.rb
67
67
  - lib/omniai/mistral/config.rb
68
+ - lib/omniai/mistral/embed.rb
68
69
  - lib/omniai/mistral/version.rb
69
70
  homepage: https://github.com/ksylvest/omniai-mistral
70
71
  licenses: