omniai 0.0.2 → 0.0.4

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: 62a5db8ecb28e379812a5dce657588fb44c55b7af4b8a2463bdb712d91b9f0a9
4
- data.tar.gz: 3d5a935c85975fb46a5062c8a4999c0f1fcdb187f2aa542863a4503791dc095b
3
+ metadata.gz: f06b4a4287ce5c0b893d4a961aee12b76b11e305908b158fc343ef0213fb7d61
4
+ data.tar.gz: c4d39d0ea4525c5b364692789b84ebe46897273afdeccab54be7375d76f0b990
5
5
  SHA512:
6
- metadata.gz: 4846e70507f51344862e5382ffcf5043b4896408eff86377d75af7439bd5cb6d865a19b84f67ae87be686c9c0be9e1005d3321896a3083ea2a0d208e051a2a6b
7
- data.tar.gz: ab185c7be3efffc942c9eb104f4ad77bec9847718f0ee91456e2fd57cd1fd2ca3206fc73f601ba964084bb0c6aa3450da17c8280c53592fa363854d19640faae
6
+ metadata.gz: 68c97d0af47fe1d7e61ead17e59f0bd116296d50fde4859cb2293df3f728295da04b1216764d258185e46fef85a2fea03a8466d84268900bde1024b376899fa1
7
+ data.tar.gz: 52bf6be629df472d71f51270f7c2534b1ec926a278801806cf062dc62eef912bda3f4af937a7f81f9db964c78fd738dd9678ca2353ec1eb3481febf354cf8021
@@ -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 :content, :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.4'
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,14 +1,14 @@
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.4
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-10 00:00:00.000000000 Z
11
+ date: 2024-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -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