omniai-mistral 1.5.0 → 1.6.1

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: c6f7b36b36c5460c0ca69d83449bcc696168a70b772fcd71dc74604a1c1b892b
4
- data.tar.gz: 737c9f1d3fa9cfceddf4a0d7cbc074b6ee0769186d7390e387e7d4193237c0c9
3
+ metadata.gz: 8ab0ad2db899898af639d14d319f8de978b4056cddc0b4015fd65663d50e343f
4
+ data.tar.gz: 8a3843dbb174c054b26a98a657b0dba537cd77f4dba1dca1baac8d3080b756e7
5
5
  SHA512:
6
- metadata.gz: 063e6252ade8a03eca3b8b29779676b549f0a89c4b6bc6c80f8e59930bbdd89c8018950d5ae7a84a4bab778416b9e7307aa75c083330271e2c0bea982f553821
7
- data.tar.gz: 2d3c40e17fcd7c3ce777fa29d271a6bf3103d9c2a76b1b8d7cfa0d8be748bbba86cf2b3c9316618cde9e0393cb673c1299f08b8198d6f76790b665b5ce9d1291
6
+ metadata.gz: 2051bf93aac8437af6805882eb9f9d514ba4af1826b8a09234b1b1e67747ba86ae477600e646dd4d63472d464c6b430ee574d95d664c3b11fce891e3848cb33d
7
+ data.tar.gz: ca1433a9f56e7b859f90e37649d4c1096d790cfe40a112061b26e5ae4d6d532a15395c7f1b93fd60745db95ecd68ca0aaf449b75d154bc597082788e6cd7f078
data/README.md CHANGED
@@ -46,21 +46,10 @@ completion.choice.message.content # 'Why did the chicken cross the road? To get
46
46
  ```
47
47
 
48
48
  ```ruby
49
- completion = client.chat({
50
- role: OmniAI::Chat::Role::USER,
51
- content: 'Is it wise to jump off a bridge?'
52
- })
53
- completion.choice.message.content # 'No.'
54
- ```
55
-
56
- ```ruby
57
- completion = client.chat([
58
- {
59
- role: OmniAI::Chat::Role::SYSTEM,
60
- content: 'You are a helpful assistant.'
61
- },
62
- 'What is the capital of Canada?',
63
- ])
49
+ completion = client.chat do |prompt|
50
+ prompt.system('You are a helpful assistant.')
51
+ prompt.user('What is the capital of Canada?')
52
+ end
64
53
  completion.choice.message.content # 'The capital of Canada is Ottawa.'
65
54
  ```
66
55
 
@@ -104,10 +93,10 @@ client.chat('Be poetic.', stream:)
104
93
  `format` takes an optional symbol (`:json`) and that sets the `response_format` to `json_object`:
105
94
 
106
95
  ```ruby
107
- completion = client.chat([
108
- { role: OmniAI::Chat::Role::SYSTEM, content: OmniAI::Chat::JSON_PROMPT },
109
- { role: OmniAI::Chat::Role::USER, content: 'What is the name of the drummer for the Beatles?' }
110
- ], format: :json)
96
+ completion = client.chat(format: :json) do |prompt|
97
+ prompt.system(OmniAI::Chat::JSON_PROMPT)
98
+ prompt.user('What is the name of the drummer for the Beatles?')
99
+ end
111
100
  JSON.parse(completion.choice.message.content) # { "name": "Ringo" }
112
101
  ```
113
102
 
@@ -32,7 +32,7 @@ module OmniAI
32
32
  # @return [Hash]
33
33
  def payload
34
34
  OmniAI::Mistral.config.chat_options.merge({
35
- messages:,
35
+ messages: @prompt.serialize,
36
36
  model: @model,
37
37
  stream: @stream.nil? ? nil : !@stream.nil?,
38
38
  temperature: @temperature,
@@ -51,9 +51,12 @@ module OmniAI
51
51
  # @param stream [Proc, nil] optional
52
52
  # @param tools [Array<OmniAI::Tool>, nil] optional
53
53
  #
54
+ # @yield [prompt] optional
55
+ # @yieldparam prompt [OmniAI::Chat::Prompt]
56
+ #
54
57
  # @return [OmniAI::Chat::Completion]
55
- def chat(messages, model: Chat::Model::MEDIUM, temperature: nil, format: nil, stream: nil, tools: nil)
56
- Chat.process!(messages, model:, temperature:, format:, stream:, tools:, client: self)
58
+ def chat(messages, model: Chat::Model::MEDIUM, temperature: nil, format: nil, stream: nil, tools: nil, &)
59
+ Chat.process!(messages, model:, temperature:, format:, stream:, tools:, client: self, &)
57
60
  end
58
61
  end
59
62
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Mistral
5
- VERSION = '1.5.0'
5
+ VERSION = '1.6.1'
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.5.0
4
+ version: 1.6.1
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-11 00:00:00.000000000 Z
11
+ date: 2024-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: event_stream_parser