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 +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 +20 -5
- 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: f06b4a4287ce5c0b893d4a961aee12b76b11e305908b158fc343ef0213fb7d61
|
4
|
+
data.tar.gz: c4d39d0ea4525c5b364692789b84ebe46897273afdeccab54be7375d76f0b990
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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,14 +1,14 @@
|
|
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.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-
|
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/
|
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
|