omniai-mistral 1.6.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/omniai/mistral/chat.rb +2 -0
- data/lib/omniai/mistral/client.rb +10 -2
- data/lib/omniai/mistral/embed.rb +38 -0
- data/lib/omniai/mistral/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6fdad55d7cfc5b9d1845a8ec2d64772e2af5cc3d74d31b3d746732bc7509b15
|
4
|
+
data.tar.gz: d31338fb81948d32cb0937a5d206bd9393a92c4fb43523477a1508941e7f2c09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
```
|
data/lib/omniai/mistral/chat.rb
CHANGED
@@ -44,7 +44,7 @@ module OmniAI
|
|
44
44
|
|
45
45
|
# @raise [OmniAI::Error]
|
46
46
|
#
|
47
|
-
# @param messages [String
|
47
|
+
# @param messages [String] optional
|
48
48
|
# @param model [String] optional
|
49
49
|
# @param format [Symbol] optional :text or :json
|
50
50
|
# @param temperature [Float, nil] optional
|
@@ -55,9 +55,17 @@ module OmniAI
|
|
55
55
|
# @yieldparam prompt [OmniAI::Chat::Prompt]
|
56
56
|
#
|
57
57
|
# @return [OmniAI::Chat::Completion]
|
58
|
-
def chat(messages, model: Chat::
|
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
|
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.
|
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-
|
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:
|