lex-openai 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7860eea429195b6d8c2e6c7d882bcd654bf14c5ce8d8439e7c07278da1e9cbb3
4
- data.tar.gz: 9ba1592c7e995a699658c6180a218295516c3d0149533264b3b22c23df063de6
3
+ metadata.gz: 90c6d63dfd5f751c914a536a7392e0d8ddfb9e8c50b06b29d714c9a27f20d958
4
+ data.tar.gz: 734c7f7eb7089efecbe0217b75f1bde7d2203593bd7298715024e1fb12ed4a5b
5
5
  SHA512:
6
- metadata.gz: f7c0f52678c76c3d59e6b6f154cb33107055377c0509da9450a76e984b4cd4623745c788da90804723650a06d5970f3a1fb71ff63cd7f30a2e953e57986e1ef7
7
- data.tar.gz: ab3a7fe72ece42b0821af4966e618148907c222bcf0faf0caf5b48fd4547e154dc9c474f44c2cf592fc8f936dca4b5b594869446f16d6fce9ba785b304039649
6
+ metadata.gz: 6d85f2b69e108f1b81b8596aed84763f66e9a02b54e981ac2228791ff017ca44238e3afc8d906e3effb47ea6c9217dfc7785b46bb04792cf7fc5bb9bf534c621
7
+ data.tar.gz: b7b973d63e125b00d5503aadcaca25127cc5529779022671af6c9fb2259de630336450cd48243e88cd0169e9c3c0973f978a3423760ec0fa4f6ac3f152eb924f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.5] - 2026-04-06
4
+
5
+ ### Added
6
+ - Credential-only identity module for Phase 8 Broker integration (`Identity` module with `provide_token`)
7
+
3
8
  ## [0.1.4] - 2026-03-31
4
9
 
5
10
  ### Added
data/CLAUDE.md CHANGED
@@ -10,8 +10,8 @@ Legion Extension that connects LegionIO to OpenAI. Provides runners for chat com
10
10
 
11
11
  **GitHub**: https://github.com/LegionIO/lex-openai
12
12
  **License**: MIT
13
- **Version**: 0.1.2
14
- **Specs**: 17 examples
13
+ **Version**: 0.1.5
14
+ **Specs**: 66 examples (8 spec files)
15
15
 
16
16
  ## Architecture
17
17
 
@@ -31,15 +31,16 @@ Legion::Extensions::Openai
31
31
 
32
32
  There is no standalone `Client` class in lex-openai. Runner modules are used directly via `extend` or by including them in a consuming class. This differs from lex-azure-ai, lex-bedrock, lex-claude, lex-foundry, and lex-xai which all ship a `Client` class.
33
33
 
34
- `Helpers::Client` is a **module** (not a class). It does not use `module_function` — instead, runner modules `extend` it so `client(...)` is available as a module-level method. `DEFAULT_BASE_URL` is `'https://api.openai.com'`.
34
+ `Helpers::Client` is a **module** (not a class). Runner modules `extend` it so `client(...)` is available as a module-level method. `DEFAULT_BASE_URL = 'https://api.openai.com'`.
35
35
 
36
36
  ## Key Design Decisions
37
37
 
38
38
  - `faraday/multipart` is required unconditionally in `Helpers::Client` — the `:multipart` middleware is always loaded. This is a hard dependency (listed in gemspec), unlike lex-gemini where it is optional.
39
- - Images (edit, variation) and Audio (transcribe, translate) runners use `Faraday::Multipart::FilePart` directly.
39
+ - `Images#edit` and `Images#variation` use `Faraday::Multipart::FilePart` directly.
40
40
  - `Images#generate` uses DALL-E 3 by default; `Images#edit` and `Images#variation` use DALL-E 2 by default.
41
41
  - Audio defaults: `model: 'tts-1'`, `voice: 'alloy'`, `response_format: 'mp3'` for speech; `model: 'whisper-1'` for transcription/translation.
42
- - All runners return `{ result: response.body }` (no `:status` key). This is consistent with lex-gemini runners. lex-claude runners add `:status` to the return hash.
42
+ - All runners return `{ result: response.body }` (no `:status` key).
43
+ - `multi_json` is NOT a declared dependency of lex-openai (unlike lex-azure-ai, lex-claude, lex-foundry, lex-xai). JSON parsing uses Faraday's built-in response middleware.
43
44
  - `include Legion::Extensions::Helpers::Lex` is guarded with `Legion::Extensions.const_defined?(:Helpers)` pattern.
44
45
 
45
46
  ## Dependencies
@@ -48,17 +49,19 @@ There is no standalone `Client` class in lex-openai. Runner modules are used dir
48
49
  |-----|---------|
49
50
  | `faraday` >= 2.0 | HTTP client |
50
51
  | `faraday-multipart` >= 1.0 | Multipart file uploads (images, audio, files) |
52
+ | `legion-cache`, `legion-crypt`, `legion-data`, `legion-json`, `legion-logging`, `legion-settings`, `legion-transport` | LegionIO core |
51
53
 
52
- Note: `multi_json` is NOT a declared dependency of lex-openai (unlike the other extensions in this category). JSON parsing uses Faraday's built-in response middleware.
54
+ Note: `multi_json` is NOT a declared dependency (differs from all other extensions in this category).
53
55
 
54
56
  ## Testing
55
57
 
56
58
  ```bash
57
59
  bundle install
58
- bundle exec rspec # 17 examples
60
+ bundle exec rspec # 66 examples
59
61
  bundle exec rubocop
60
62
  ```
61
63
 
62
64
  ---
63
65
 
64
66
  **Maintained By**: Matthew Iverson (@Esity)
67
+ **Last Updated**: 2026-04-06
data/README.md CHANGED
@@ -100,7 +100,6 @@ puts image[:result]['data'].first['url']
100
100
 
101
101
  - `faraday` >= 2.0 - HTTP client
102
102
  - `faraday-multipart` >= 1.0 - Multipart file uploads (images, audio, files)
103
- - `multi_json` - JSON parser abstraction
104
103
 
105
104
  ## Requirements
106
105
 
@@ -114,6 +113,10 @@ puts image[:result]['data'].first['url']
114
113
  - `legion-llm` — High-level LLM interface including OpenAI via ruby_llm
115
114
  - `extensions-ai/CLAUDE.md` — Architecture patterns shared across all AI extensions
116
115
 
116
+ ## Version
117
+
118
+ 0.1.5
119
+
117
120
  ## License
118
121
 
119
122
  MIT
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module Openai
6
+ module Identity
7
+ module_function
8
+
9
+ def provider_name = :openai
10
+ def provider_type = :credential
11
+ def facing = nil
12
+ def capabilities = %i[credentials]
13
+
14
+ def resolve(canonical_name: nil) # rubocop:disable Lint/UnusedMethodArgument
15
+ nil
16
+ end
17
+
18
+ def provide_token
19
+ api_key = resolve_api_key
20
+ return nil unless api_key
21
+
22
+ Legion::Identity::Lease.new(
23
+ provider: :openai,
24
+ credential: api_key,
25
+ expires_at: nil,
26
+ renewable: false,
27
+ issued_at: Time.now,
28
+ metadata: { credential_type: :api_key }
29
+ )
30
+ end
31
+
32
+ def resolve_api_key
33
+ return nil unless defined?(Legion::Settings)
34
+
35
+ value = Legion::Settings.dig(:llm, :providers, :openai, :api_key)
36
+ value = value.find { |v| v && !v.empty? } if value.is_a?(Array)
37
+ value unless value.nil? || (value.is_a?(String) && (value.empty? || value.start_with?('env://')))
38
+ end
39
+
40
+ private_class_method :resolve_api_key
41
+ end
42
+ end
43
+ end
44
+ end
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Openai
6
- VERSION = '0.1.4'
6
+ VERSION = '0.1.5'
7
7
  end
8
8
  end
9
9
  end
@@ -9,6 +9,7 @@ require 'legion/extensions/openai/runners/audio'
9
9
  require 'legion/extensions/openai/runners/embeddings'
10
10
  require 'legion/extensions/openai/runners/files'
11
11
  require 'legion/extensions/openai/runners/moderations'
12
+ require 'legion/extensions/openai/identity'
12
13
 
13
14
  module Legion
14
15
  module Extensions
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-openai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -157,6 +157,7 @@ files:
157
157
  - lex-openai.gemspec
158
158
  - lib/legion/extensions/openai.rb
159
159
  - lib/legion/extensions/openai/helpers/client.rb
160
+ - lib/legion/extensions/openai/identity.rb
160
161
  - lib/legion/extensions/openai/runners/audio.rb
161
162
  - lib/legion/extensions/openai/runners/chat.rb
162
163
  - lib/legion/extensions/openai/runners/embeddings.rb