omniai-mistral 1.3.0 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 382f5eb9d01087dbab76c84890ddd1414e89017714c211ec4163206f56f7557b
4
- data.tar.gz: dad60217422c646066cd2c0a60339d52cd4347df31175ec889fdfbd735e19a33
3
+ metadata.gz: 253b0ae91739077ea70a562cad40ce7c16ead3a62a7650ae7511f4680e34c96b
4
+ data.tar.gz: bfed7d64757f41170581aafdc1726571bb399b2a6ffd845dff9062a2ebf21c7e
5
5
  SHA512:
6
- metadata.gz: 79e0f8d805a3d577facbbd6477be06ca38de8da9370987e6ff0bea1bc9175222d12ea188d15769ecb571849ff1c3e06f27ff4ca7ef01d98b82d1651dc0670656
7
- data.tar.gz: 773bc4ba186ee0a1ae2d27c8ca1862dfafd5d44b90ed99993f8e420c5eba89422855ba433ea14c2d894a327e8e44194df1ff25f7d4436c7ff335f0932d5701e2
6
+ metadata.gz: a4dee74fcf4169cf99adeaa5239f9c6afa33f90b007b9d8c5e8368c332ab8e6a4b291e482d55429633957a81c40b2871b2e57ecdd98e99eb233fecd101d57ad6
7
+ data.tar.gz: 2d3256886c38c5823cf7fcdf2d6d377c2128cc375624aa7c596dd9bb6d308d780a760917b6c6487c18b46a2dbb82636eb05bb82cd692b63146963ecd4b58956f
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  gem 'rake'
8
-
9
8
  gem 'rspec'
10
9
  gem 'rspec_junit_formatter'
11
10
  gem 'rubocop'
@@ -13,3 +12,4 @@ gem 'rubocop-rake'
13
12
  gem 'rubocop-rspec'
14
13
  gem 'simplecov'
15
14
  gem 'webmock'
15
+ gem 'yard'
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,11 +32,12 @@ 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,
39
39
  response_format: (JSON_RESPONSE_FORMAT if @format.eql?(:json)),
40
+ tools: @tools&.map(&:prepare),
40
41
  }).compact
41
42
  end
42
43
 
@@ -49,10 +49,11 @@ module OmniAI
49
49
  # @param format [Symbol] optional :text or :json
50
50
  # @param temperature [Float, nil] optional
51
51
  # @param stream [Proc, nil] optional
52
+ # @param tools [Array<OmniAI::Tool>, nil] optional
52
53
  #
53
54
  # @return [OmniAI::Chat::Completion]
54
- def chat(messages, model: Chat::Model::MEDIUM, temperature: nil, format: nil, stream: nil)
55
- Chat.process!(messages, model:, temperature:, format:, stream:, client: self)
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)
56
57
  end
57
58
  end
58
59
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Mistral
5
- VERSION = '1.3.0'
5
+ VERSION = '1.6.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.3.0
4
+ version: 1.6.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-06-21 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
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubygems_version: 3.5.3
91
+ rubygems_version: 3.5.14
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: A generalized framework for interacting with Mistral