omniai 0.0.6 → 0.0.8

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: eb51f64b3514f196e07be3b77f2ca538878602af864f5c2c49e5e2506f05bfaf
4
- data.tar.gz: f4069c9f19fbcc6f2caf90ab28e32ed83c8700b2ea8c686059afc612997b1ea6
3
+ metadata.gz: b478ff0decf827e07f67c3c85973ad576f546980417f82ff5f71949c99157e22
4
+ data.tar.gz: edcd0f60037d10fca5aec3ecc6cbd08c0c9b1c42aa9353506c232821cbd0fe0f
5
5
  SHA512:
6
- metadata.gz: 06ece9d4bd7db17c57bff05f3323ba2ddd5e10803a5e5b460d8f5c66ffad932880230270d5a3e5e3653e46c6aaeec0926cff740414c9bb8d0e799062e4ce3139
7
- data.tar.gz: 8443711ec0a65da572ce47a2da284ef63e277bdffc64663ab0577c4ded90105faaa666819f09b9d8ac2d2e457db8f4c07303b987ebb96e719648dd8624e419c0
6
+ metadata.gz: 69d8116cf9313da66fc89857332d8efb9e2005f007474dd377ec8c34ffb5c18e22155740390acb793f255447399f176605f0306e94c99c0e160346581fd1e597
7
+ data.tar.gz: 5c7975664071ff8158d5fd9e33fac37f7874b856d319edb0555deeefb78ac70e1dd7c13ffde015a5b0029c4b1ad26554d34ba0ca294bbf8acc81365adef1705c
@@ -19,23 +19,20 @@ module OmniAI
19
19
  # client.chat.completion(messages, model: "...", temperature: 0.0, format: :text)
20
20
  class Request
21
21
  # @param client [OmniAI::Client] the client
22
- # @param messages [String]
23
- # @param model [String]
24
- # @param temperature [Float]
25
- # @param format [Symbol] either :text or :json
26
- def initialize(client:, messages:, model:, temperature: 0.0, format: :text)
22
+ # @param messages [String] required
23
+ # @param model [String] required
24
+ # @param temperature [Float, nil] optional
25
+ # @param stream [Proc, nil] optional
26
+ # @param format [Symbol, nil] optional - :text or :json
27
+ def initialize(client:, messages:, model:, temperature: nil, stream: nil, format: nil)
27
28
  @client = client
28
29
  @messages = messages
29
30
  @model = model
30
31
  @temperature = temperature
32
+ @stream = stream
31
33
  @format = format
32
34
  end
33
35
 
34
- # @param prompt [String, Message]
35
- # @param model [String]
36
- # @param format [Symbol] either :text or :json
37
- # @param temperature [Float]
38
- # @return [Hash]
39
36
  # @raise [ExecutionError]
40
37
  def process!
41
38
  response = request!
data/lib/omniai/chat.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniAI
4
- # An abstract class that provides an interface for chatting for various vendors (e.g. OpenAI::ChatGPT).
4
+ # An abstract class that provides an interface for chatting for various vendors (e.g. OpenAI’s ChatGPT).
5
5
  #
6
6
  # Usage:
7
7
  #
@@ -23,13 +23,14 @@ module OmniAI
23
23
 
24
24
  # @raise [OmniAI::Error]
25
25
  #
26
- # @param messages [String]
27
- # @param model [String]
28
- # @param format [Symbol] either :text or :json
29
- # @param temperature [Float]
26
+ # @param messages [String, Array, Hash, OmnniAI::Chat::Message]
27
+ # @param model [String] optional
28
+ # @param format [Symbol] optional :text or :json
29
+ # @param temperature [Float, nil] optional
30
+ # @param stream [Proc, nil] optional
30
31
  #
31
32
  # @return [OmniAI::Chat::Request]
32
- def completion(messages, model:, temperature: 0.0, format: :text)
33
+ def completion(messages, model:, temperature: nil, format: nil, stream: nil)
33
34
  raise NotImplementedError, "#{self.class.name}#completion undefined"
34
35
  end
35
36
  end
data/lib/omniai/client.rb CHANGED
@@ -6,7 +6,7 @@ module OmniAI
6
6
  # Usage:
7
7
  #
8
8
  # class OmniAI::OpenAI::Client < OmniAI::Client
9
- # def initialize(api_key: ENV.fetch('OPENAI_API_KEY'))
9
+ # def initialize(api_key: ENV.fetch('OPENAI_API_KEY'), logger: nil)
10
10
  # super
11
11
  # end
12
12
  #
@@ -21,13 +21,15 @@ module OmniAI
21
21
  attr_accessor :api_key
22
22
 
23
23
  # @param api_key [String]
24
- def initialize(api_key:)
24
+ # @param logger [Logger]
25
+ def initialize(api_key:, logger: nil)
25
26
  @api_key = api_key
27
+ @logger = logger
26
28
  end
27
29
 
28
30
  # @return [HTTP::Client]
29
31
  def connection
30
- HTTP.auth("Bearer #{api_key}")
32
+ raise NotImplementedError, "#{self.class.name}#connection undefined"
31
33
  end
32
34
 
33
35
  # @return [OmniAI::Chat] an instance of OmniAI::Chat
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniAI
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.8'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre