omniai-openai 1.2.1 → 1.3.0

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: e3afb339ec2a0e69d5a268fd134aae4119e3140ccad493f22d7db43b817145a4
4
- data.tar.gz: f49c3cfd25228e49555981cc93e05e6702d3ce4edde9fa07277bc68c83312361
3
+ metadata.gz: 8a95f906f1bf54382e8ace7ae6b1622ad22d2502a23c4804038b1ca66ff43086
4
+ data.tar.gz: 6694a63f7f76e2d41220a18e2ea852a19e956a8258761b71e9a0ec747197c9a9
5
5
  SHA512:
6
- metadata.gz: 4455db3523b81301793b936528312394cb0f98b8f51ad7a49f5f6fe5811c2969dcaf679649deb0cb90bfec5fdf5838f3ba6444eea645d560ceaaaf96b9c15f5f
7
- data.tar.gz: 804f70fd6067cba057aaa7dbbe7d65f5edaa389e5315fb4a107f154fbafa1139d33ad637439e8b838036767c02e4e2cfed0d69c43c0a36cb805bb4dfe21eb907
6
+ metadata.gz: c19cd98191bd1826f24af180bcf87e96670fc162c6555bf368e4eda9305cdf5fa465585c74764d55481181752f563a581b09e3b1583220df70d9b227861a51d8
7
+ data.tar.gz: b6eb2fdeb33dcf4dda02f2b608e13ae3cc29c687b0c9eb31bdecaf72d07548b0201c68efe3e40cd754b368d2b2f84813e5eeb207878dbc6355fe4a67a8308f3e
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![CircleCI](https://circleci.com/gh/ksylvest/omniai-openai.svg?style=svg)](https://circleci.com/gh/ksylvest/omniai-openai)
4
4
 
5
- An OpenAI implementation of the [OmniAI](https://github.com/ksylvest/omniai) APIs.
5
+ An OpenAI implementation of the [OmniAI](https://github.com/ksylvest/omniai) interface supporting ChatGPT, Whisper, Text-to-Voice, Voice-to-Text, and more. This library is community maintained.
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,16 +22,19 @@ module OmniAI
22
22
  class Client < OmniAI::Client
23
23
  VERSION = 'v1'
24
24
 
25
- # @param api_key [String] optional - defaults to `OmniAI::OpenAI.config.api_key`
26
- # @param project_id [String] optional - defaults to `OmniAI::OpenAI.config.project`
27
- # @param organization_id [String] optional - defaults to `OmniAI::OpenAI.config.organization`
28
- # @param logger [Logger] optional - defaults to `OmniAI::OpenAI.config.logger`
25
+ # @param api_key [String, nil] optional - defaults to `OmniAI::OpenAI.config.api_key`
26
+ # @param host [String] optional - defaults to `OmniAI::OpenAI.config.host`
27
+ # @param project [String, nil] optional - defaults to `OmniAI::OpenAI.config.project`
28
+ # @param organization [String, nil] optional - defaults to `OmniAI::OpenAI.config.organization`
29
+ # @param logger [Logger, nil] optional - defaults to `OmniAI::OpenAI.config.logger`
30
+ # @param timeout [Integer, nil] optional - defaults to `OmniAI::OpenAI.config.timeout`
29
31
  def initialize(
30
32
  api_key: OmniAI::OpenAI.config.api_key,
33
+ host: OmniAI::OpenAI.config.host,
31
34
  organization: OmniAI::OpenAI.config.organization,
32
35
  project: OmniAI::OpenAI.config.project,
33
36
  logger: OmniAI::OpenAI.config.logger,
34
- host: OmniAI::OpenAI.config.host
37
+ timeout: OmniAI::OpenAI.config.timeout
35
38
  )
36
39
  if api_key.nil? && host.eql?(Config::DEFAULT_HOST)
37
40
  raise(
@@ -40,7 +43,7 @@ module OmniAI
40
43
  )
41
44
  end
42
45
 
43
- super(api_key:, host:, logger:)
46
+ super(api_key:, host:, logger:, timeout:)
44
47
 
45
48
  @organization = organization
46
49
  @project = project
@@ -49,7 +52,7 @@ module OmniAI
49
52
  # @return [HTTP::Client]
50
53
  def connection
51
54
  @connection ||= begin
52
- http = HTTP.persistent(@host)
55
+ http = super
53
56
  http = http.auth("Bearer #{@api_key}") if @api_key
54
57
  http = http.headers('OpenAI-Organization': @organization) if @organization
55
58
  http = http.headers('OpenAI-Project': @project) if @project
@@ -2,21 +2,36 @@
2
2
 
3
3
  module OmniAI
4
4
  module OpenAI
5
- # Configuration for managing the OpenAI `api_key` / `organization` / `project` / `logger`.
5
+ # Configuration for OpenAI.
6
6
  class Config < OmniAI::Config
7
- attr_accessor :organization, :project, :chat_options, :transcribe_options, :speak_options
8
-
9
7
  DEFAULT_HOST = 'https://api.openai.com'
10
8
 
11
- def initialize
12
- super
13
- @api_key = ENV.fetch('OPENAI_API_KEY', nil)
14
- @organization = ENV.fetch('OPENAI_ORGANIZATION', nil)
15
- @project = ENV.fetch('OPENAI_PROJECT', nil)
16
- @host = ENV.fetch('OPENAI_HOST', DEFAULT_HOST)
17
- @chat_options = {}
18
- @transcribe_options = {}
19
- @speak_options = {}
9
+ # @!attribute [rw] organization
10
+ # @return [String, nil] passed as `OpenAI-Organization` if specified
11
+ attr_accessor :organization
12
+
13
+ # @!attribute [rw] project
14
+ # @return [String, nil] passed as `OpenAI-Organization` if specified
15
+ attr_accessor :project
16
+
17
+ # @param api_key [String, nil] optional - defaults to `ENV['OPENAI_API_KEY']`
18
+ # @param host [String, nil] optional - defaults to ENV['OPENAI_HOST'] w/ fallback to `DEFAULT_HOST`
19
+ # @param organization [String, nil] optional - defaults to `ENV['OPENAI_ORGANIZATION']`
20
+ # @param project [String, nil] optional - defaults to `ENV['OPENAI_PROJECT']`
21
+ # @param logger [Logger, nil] optional
22
+ # @param timeout [Integer, Hash, nil] optional
23
+ def initialize(
24
+ api_key: ENV.fetch('OPENAI_API_KEY', nil),
25
+ host: ENV.fetch('OPENAI_HOST', DEFAULT_HOST),
26
+ organization: ENV.fetch('OPENAI_ORGANIZATION', nil),
27
+ project: ENV.fetch('OPENAI_PROJECT', nil),
28
+ logger: nil,
29
+ timeout: nil
30
+ )
31
+ super(api_key:, host:, logger:, timeout:)
32
+
33
+ @organization = organization
34
+ @project = project
20
35
  end
21
36
  end
22
37
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module OpenAI
5
- VERSION = '1.2.1'
5
+ VERSION = '1.3.0'
6
6
  end
7
7
  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.2.1
4
+ version: 1.3.0
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-20 00:00:00.000000000 Z
11
+ date: 2024-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: event_stream_parser