omniai-mistral 1.2.0 → 1.5.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: 422f9590834021e3c89c5289fbab907797748ec42b486748f55db20845a9005f
4
- data.tar.gz: e26a30e7e9532e7a0589f7c3fd076a621771693a8d2af3814f28ccd707bba12e
3
+ metadata.gz: c6f7b36b36c5460c0ca69d83449bcc696168a70b772fcd71dc74604a1c1b892b
4
+ data.tar.gz: 737c9f1d3fa9cfceddf4a0d7cbc074b6ee0769186d7390e387e7d4193237c0c9
5
5
  SHA512:
6
- metadata.gz: 0ccec2ed5709e7993f8e0936959d4186e6e08458add50233ded53a0163eaab0dad4dd5d2183ba68add2c2346d1237676705eebca195fd63222db34396c962ac6
7
- data.tar.gz: 58913437e42cb83b129920c12c3ce968cd3191e4d496f701f63cdd31509cdbd11e5810956d9ead04b1dfbb10c89b86cbee89c35d45a58f727da3ef5ea43c26d5
6
+ metadata.gz: 063e6252ade8a03eca3b8b29779676b549f0a89c4b6bc6c80f8e59930bbdd89c8018950d5ae7a84a4bab778416b9e7307aa75c083330271e2c0bea982f553821
7
+ data.tar.gz: 2d3c40e17fcd7c3ce777fa29d271a6bf3103d9c2a76b1b8d7cfa0d8be748bbba86cf2b3c9316618cde9e0393cb673c1299f08b8198d6f76790b665b5ce9d1291
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'
@@ -37,6 +37,7 @@ module OmniAI
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
 
@@ -24,21 +24,22 @@ module OmniAI
24
24
 
25
25
  # @param api_key [String] optional - defaults to `OmniAI::Mistral.config.api_key`
26
26
  # @param host [String] optional - defaults to `OmniAI::Mistral.config.host`
27
+ # @param logger [Logger] optional - defaults to `OmniAI::Mistral.config.logger`
28
+ # @param timeout [Integer] optional - defaults to `OmniAI::Mistral.config.timeout`
27
29
  def initialize(
28
30
  api_key: OmniAI::Mistral.config.api_key,
31
+ host: OmniAI::Mistral.config.host,
29
32
  logger: OmniAI::Mistral.config.logger,
30
- host: OmniAI::Mistral.config.host
33
+ timeout: OmniAI::Mistral.config.timeout
31
34
  )
32
35
  raise(ArgumentError, %(ENV['MISTRAL_API_KEY'] must be defined or `api_key` must be passed)) if api_key.nil?
33
36
 
34
- super(api_key:, logger:)
35
-
36
- @host = host
37
+ super
37
38
  end
38
39
 
39
40
  # @return [HTTP::Client]
40
41
  def connection
41
- @connection ||= HTTP.auth("Bearer #{api_key}").persistent(@host)
42
+ @connection ||= super.auth("Bearer #{api_key}")
42
43
  end
43
44
 
44
45
  # @raise [OmniAI::Error]
@@ -48,10 +49,11 @@ module OmniAI
48
49
  # @param format [Symbol] optional :text or :json
49
50
  # @param temperature [Float, nil] optional
50
51
  # @param stream [Proc, nil] optional
52
+ # @param tools [Array<OmniAI::Tool>, nil] optional
51
53
  #
52
54
  # @return [OmniAI::Chat::Completion]
53
- def chat(messages, model: Chat::Model::MEDIUM, temperature: nil, format: nil, stream: nil)
54
- 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)
55
57
  end
56
58
  end
57
59
  end
@@ -2,15 +2,21 @@
2
2
 
3
3
  module OmniAI
4
4
  module Mistral
5
- # Config for the Mistral `api_key` / `host` / `logger`, `chat_options`.
5
+ # Configuration for Mistral.
6
6
  class Config < OmniAI::Config
7
- attr_accessor :chat_options
7
+ DEFAULT_HOST = 'https://api.mistral.ai'
8
8
 
9
- def initialize
9
+ # @param api_key [String, nil] optional - defaults to `ENV['MISTRAL_API_KEY']`
10
+ # @param host [String, nil] optional - defaults to `ENV['MISTRAL_HOST'] w/ fallback to `DEFAULT_HOST`
11
+ # @param logger [Logger, nil] optional - defaults to
12
+ # @param timeout [Integer, Hash, nil] optional
13
+ def initialize(
14
+ api_key: ENV.fetch('MISTRAL_API_KEY', nil),
15
+ host: ENV.fetch('MISTRAL_HOST', DEFAULT_HOST),
16
+ logger: nil,
17
+ timeout: nil
18
+ )
10
19
  super
11
- @api_key = ENV.fetch('MISTRAL_API_KEY', nil)
12
- @host = ENV.fetch('MISTRAL_HOST', 'https://api.mistral.ai')
13
- @chat_options = {}
14
20
  end
15
21
  end
16
22
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Mistral
5
- VERSION = '1.2.0'
5
+ VERSION = '1.5.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.2.0
4
+ version: 1.5.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-20 00:00:00.000000000 Z
11
+ date: 2024-07-11 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