omniai-openai 1.8.1 → 1.8.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/README.md +13 -1
- data/lib/omniai/openai/chat.rb +3 -1
- data/lib/omniai/openai/client.rb +9 -0
- data/lib/omniai/openai/embed.rb +1 -1
- data/lib/omniai/openai/speak.rb +1 -1
- data/lib/omniai/openai/thread/message.rb +1 -1
- data/lib/omniai/openai/thread/run.rb +1 -1
- data/lib/omniai/openai/transcribe.rb +1 -1
- data/lib/omniai/openai/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd5c0c0055668349c161b1bcc599bf4c3f581dcdf25ec5c4c15084d2125686e3
|
4
|
+
data.tar.gz: 6402cb51f542d42fd567e4ee2d9b07ad5527e6d0c47f82ab2cfe608ea113341f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 426395b6eefdce402f20992b2ed3e10b80de32aa756dd32975c035422eeba4c1d7d1fd47ebbf7f79bc98ea92b6b468d4dc16886f6e59cb0a23490f0adfd0af22
|
7
|
+
data.tar.gz: 980902dfefe3a523d03c12f037ba3d5b92cdf894b12f7d42d94246879648d3ba6f32538a6f72ff1549882cbca78fbf7e5eb4ffe607948ce59e793206e3edb83b
|
data/README.md
CHANGED
@@ -23,9 +23,10 @@ client = OmniAI::OpenAI::Client.new
|
|
23
23
|
A client may also be passed the following options:
|
24
24
|
|
25
25
|
- `api_key` (required - default is `ENV['OPENAI_API_KEY']`)
|
26
|
+
- `api_prefix` (optional) - used with a host when necessary
|
26
27
|
- `organization` (optional)
|
27
28
|
- `project` (optional)
|
28
|
-
- `host` (optional) useful for usage with Ollama or
|
29
|
+
- `host` (optional) useful for usage with Ollama, LocalAI or other OpenAI API compatible services
|
29
30
|
|
30
31
|
### Configuration
|
31
32
|
|
@@ -60,6 +61,17 @@ client = OmniAI::OpenAI::Client.new(host: 'http://localhost:11434', api_key: nil
|
|
60
61
|
|
61
62
|
_For details on installation or running Ollama checkout [the project README](https://github.com/ollama/ollama)._
|
62
63
|
|
64
|
+
#### Usage with [OpenRouter](https://open_router.ai/)
|
65
|
+
|
66
|
+
Other fee-based systems/services have adopted all or some of the OpenAI API. For example [open_router.ai](https://open_router.ai) is a web-services that provides access to many models and providers using their own as well as an OpenAI API.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
client = OmniAI::OpenAI::Client.new(
|
70
|
+
host: 'https://open_router.ai',
|
71
|
+
api_key: ENV['OPENROUTER_API_KEY'],
|
72
|
+
api_prefix: '/api')
|
73
|
+
```
|
74
|
+
|
63
75
|
### Chat
|
64
76
|
|
65
77
|
A chat completion is generated by passing in a simple text prompt:
|
data/lib/omniai/openai/chat.rb
CHANGED
@@ -20,6 +20,8 @@ module OmniAI
|
|
20
20
|
GPT_4 = 'gpt-4'
|
21
21
|
GPT_4_TURBO = 'gpt-4-turbo'
|
22
22
|
GPT_3_5_TURBO = 'gpt-3.5-turbo'
|
23
|
+
O1_MINI = 'o1-mini'
|
24
|
+
O1_PREVIEW = 'o1-preview'
|
23
25
|
end
|
24
26
|
|
25
27
|
DEFAULT_MODEL = Model::GPT_4O
|
@@ -40,7 +42,7 @@ module OmniAI
|
|
40
42
|
|
41
43
|
# @return [String]
|
42
44
|
def path
|
43
|
-
"/#{OmniAI::OpenAI::Client::VERSION}/chat/completions"
|
45
|
+
"#{@client.api_prefix}/#{OmniAI::OpenAI::Client::VERSION}/chat/completions"
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
data/lib/omniai/openai/client.rb
CHANGED
@@ -22,7 +22,10 @@ module OmniAI
|
|
22
22
|
class Client < OmniAI::Client
|
23
23
|
VERSION = 'v1'
|
24
24
|
|
25
|
+
attr_reader :api_prefix
|
26
|
+
|
25
27
|
# @param api_key [String, nil] optional - defaults to `OmniAI::OpenAI.config.api_key`
|
28
|
+
# @param api_prefix [String, nil] optional - defaults to empty string
|
26
29
|
# @param host [String] optional - defaults to `OmniAI::OpenAI.config.host`
|
27
30
|
# @param project [String, nil] optional - defaults to `OmniAI::OpenAI.config.project`
|
28
31
|
# @param organization [String, nil] optional - defaults to `OmniAI::OpenAI.config.organization`
|
@@ -30,6 +33,7 @@ module OmniAI
|
|
30
33
|
# @param timeout [Integer, nil] optional - defaults to `OmniAI::OpenAI.config.timeout`
|
31
34
|
def initialize(
|
32
35
|
api_key: OmniAI::OpenAI.config.api_key,
|
36
|
+
api_prefix: '',
|
33
37
|
host: OmniAI::OpenAI.config.host,
|
34
38
|
organization: OmniAI::OpenAI.config.organization,
|
35
39
|
project: OmniAI::OpenAI.config.project,
|
@@ -47,6 +51,11 @@ module OmniAI
|
|
47
51
|
|
48
52
|
@organization = organization
|
49
53
|
@project = project
|
54
|
+
|
55
|
+
@api_prefix = api_prefix
|
56
|
+
return if @api_prefix.empty? || @api_prefix.start_with('/')
|
57
|
+
|
58
|
+
@api_prefix.prepend('/')
|
50
59
|
end
|
51
60
|
|
52
61
|
# @return [HTTP::Client]
|
data/lib/omniai/openai/embed.rb
CHANGED
data/lib/omniai/openai/speak.rb
CHANGED
@@ -199,7 +199,7 @@ module OmniAI
|
|
199
199
|
|
200
200
|
# @return [String]
|
201
201
|
def path
|
202
|
-
"/#{OmniAI::OpenAI::Client::VERSION}/threads/#{@thread_id}/messages#{"/#{@id}" if @id}"
|
202
|
+
"#{@client.api_prefix}/#{OmniAI::OpenAI::Client::VERSION}/threads/#{@thread_id}/messages#{"/#{@id}" if @id}"
|
203
203
|
end
|
204
204
|
end
|
205
205
|
end
|
@@ -252,7 +252,7 @@ module OmniAI
|
|
252
252
|
|
253
253
|
# @return [String]
|
254
254
|
def path
|
255
|
-
"/#{OmniAI::OpenAI::Client::VERSION}/threads/#{@thread_id}/runs#{"/#{@id}" if @id}"
|
255
|
+
"#{@client.api_prefix}/#{OmniAI::OpenAI::Client::VERSION}/threads/#{@thread_id}/runs#{"/#{@id}" if @id}"
|
256
256
|
end
|
257
257
|
end
|
258
258
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniai-openai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.3
|
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-
|
11
|
+
date: 2024-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: event_stream_parser
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.5.
|
109
|
+
rubygems_version: 3.5.18
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: A generalized framework for interacting with OpenAI
|