omniai 0.0.2 → 0.0.3

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: 62a5db8ecb28e379812a5dce657588fb44c55b7af4b8a2463bdb712d91b9f0a9
4
- data.tar.gz: 3d5a935c85975fb46a5062c8a4999c0f1fcdb187f2aa542863a4503791dc095b
3
+ metadata.gz: 8d54c88d48becdd4c496114b93841cf6dd32ba294a5cbf9828a0d0d4d28a023e
4
+ data.tar.gz: 8f8bb67797a1fa993cd5dc202d60e78c041ec184cf8120eae170e1b821228c62
5
5
  SHA512:
6
- metadata.gz: 4846e70507f51344862e5382ffcf5043b4896408eff86377d75af7439bd5cb6d865a19b84f67ae87be686c9c0be9e1005d3321896a3083ea2a0d208e051a2a6b
7
- data.tar.gz: ab185c7be3efffc942c9eb104f4ad77bec9847718f0ee91456e2fd57cd1fd2ca3206fc73f601ba964084bb0c6aa3450da17c8280c53592fa363854d19640faae
6
+ metadata.gz: 8f0a3651c5eb608d0aba74c8c8ae06d4def73fc519fc4cbef6c8b2a8c3434d00cd469e24eaafc8f07193cb028c93984e459c7ffc65e89e56bfc30e0ebc879a05
7
+ data.tar.gz: 21be334bdd435bfb7b9c449556cce86dde4e33dd0d84bcd285cb4b52e438ed93ca387356821f76bce3064f3bc31be3446f43773456156976d0f33fcdceb89243
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAI
4
+ class Chat
5
+ # A choice returned by the API.
6
+ class Choice
7
+ attr_accessor :index, :message, :role
8
+
9
+ # @param index [Integer]
10
+ # @param message [OmniAI::Chat::Message]
11
+ # @param role [String]
12
+ def initialize(index:, message:)
13
+ @index = index
14
+ @message = message
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAI
4
+ class Chat
5
+ # A message returned by the API.
6
+ class Message
7
+ attr_accessor :index, :message, :role
8
+
9
+ # @param content [Integer]
10
+ # @param role [String]
11
+ def initialize(content:, role:)
12
+ @content = content
13
+ @role = role
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OmniAI
4
4
  class Chat
5
- # An abstract class that provides an interface for chatting for various vendors (e.g. OpenAI::OpenAI::ChatGPT::Completion).
5
+ # An abstract class that provides a consistent interface for processing chat requests.
6
6
  #
7
7
  # Usage:
8
8
  #
@@ -17,7 +17,7 @@ module OmniAI
17
17
  # Once defined, the subclass can be used to interface with the vendor's chat API as follows:
18
18
  #
19
19
  # client.chat.completion(messages, model: "...", temperature: 0.0, format: :text)
20
- class Completion
20
+ class Request
21
21
  # @param client [OmniAI::Client] the client
22
22
  # @param messages [String]
23
23
  # @param model [String]
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAI
4
+ class Chat
5
+ # An abstract class that provides a consistent interface for processing chat responses.
6
+ #
7
+ # Usage:
8
+ #
9
+ # class OmniAI::OpenAI::Chat::Response < OmniAI::Chat::Response
10
+ # def choices
11
+ # # TODO: implement
12
+ # end
13
+ # end
14
+ class Response
15
+ attr_accessor :data
16
+
17
+ # @param data [Hash]
18
+ def initialize(data:)
19
+ @data = data
20
+ end
21
+
22
+ # @param [index] [Integer]
23
+ # @return [OmniAI::Chat::Choice]
24
+ def choice(index: 0)
25
+ choices[index]
26
+ end
27
+
28
+ # @return [Array<OmniAI::Chat::Choice>]
29
+ def choices
30
+ raise NotImplementedError, "#{self.class.name}#choices undefined"
31
+ end
32
+ end
33
+ end
34
+ end
data/lib/omniai/chat.rb CHANGED
@@ -22,11 +22,13 @@ module OmniAI
22
22
  end
23
23
 
24
24
  # @raise [OmniAI::Error]
25
+ #
25
26
  # @param messages [String]
26
27
  # @param model [String]
27
28
  # @param format [Symbol] either :text or :json
28
29
  # @param temperature [Float]
29
- # @return [OmniAI::Chat::Completion] an instance of OmniAI::Chat::Completion
30
+ #
31
+ # @return [OmniAI::Chat::Request]
30
32
  def completion(messages, model:, temperature: 0.0, format: :text)
31
33
  raise NotImplementedError, "#{self.class.name}#completion undefined"
32
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniAI
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
data/lib/omniai.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'http'
4
+ require 'zeitwerk'
4
5
 
5
- require_relative 'omniai/version'
6
- require_relative 'omniai/client'
7
- require_relative 'omniai/chat'
8
- require_relative 'omniai/chat/completion'
6
+ loader = Zeitwerk::Loader.for_gem
7
+ loader.inflector.inflect 'omniai' => 'OmniAI'
8
+ loader.setup
9
9
 
10
10
  module OmniAI
11
11
  class Error < StandardError; 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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: zeitwerk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: An interface for OpenAI's ChatGPT, Google's Gemini, Anthropic's Claude,
28
42
  Mistral's LeChat, etc.
29
43
  email:
@@ -38,15 +52,16 @@ files:
38
52
  - bin/setup
39
53
  - lib/omniai.rb
40
54
  - lib/omniai/chat.rb
41
- - lib/omniai/chat/completion.rb
42
- - lib/omniai/chat/completion/response.rb
55
+ - lib/omniai/chat/choice.rb
56
+ - lib/omniai/chat/message.rb
57
+ - lib/omniai/chat/request.rb
58
+ - lib/omniai/chat/response.rb
43
59
  - lib/omniai/client.rb
44
60
  - lib/omniai/version.rb
45
61
  homepage: https://github.com/ksylvest/omniai
46
62
  licenses: []
47
63
  metadata:
48
64
  homepage_uri: https://github.com/ksylvest/omniai
49
- source_code_uri: https://github.com/ksylvest/omniai
50
65
  changelog_uri: https://github.com/ksylvest/omniai/releases
51
66
  rubygems_mfa_required: 'true'
52
67
  post_install_message:
File without changes