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 +4 -4
- data/lib/omniai/chat/choice.rb +18 -0
- data/lib/omniai/chat/message.rb +17 -0
- data/lib/omniai/chat/{completion.rb → request.rb} +2 -2
- data/lib/omniai/chat/response.rb +34 -0
- data/lib/omniai/chat.rb +3 -1
- data/lib/omniai/version.rb +1 -1
- data/lib/omniai.rb +4 -4
- metadata +19 -4
- data/lib/omniai/chat/completion/response.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d54c88d48becdd4c496114b93841cf6dd32ba294a5cbf9828a0d0d4d28a023e
|
4
|
+
data.tar.gz: 8f8bb67797a1fa993cd5dc202d60e78c041ec184cf8120eae170e1b821228c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
-
#
|
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
|
data/lib/omniai/version.rb
CHANGED
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
|
-
|
6
|
-
|
7
|
-
|
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.
|
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/
|
42
|
-
- lib/omniai/chat/
|
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
|