lex-llm-anthropic 0.3.7 → 0.3.8
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/.github/workflows/ci.yml +6 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -3
- data/README.md +6 -1
- data/lex-llm-anthropic.gemspec +1 -1
- data/lib/legion/extensions/llm/anthropic/provider.rb +16 -21
- data/lib/legion/extensions/llm/anthropic/translator.rb +14 -2
- data/lib/legion/extensions/llm/anthropic/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: 9e8444443bbbabe4465a76230ce1b70e3af49ff25529870b5dea72a0f8218b76
|
|
4
|
+
data.tar.gz: c16f2c252c9da40e855994e9b5a1aa6924185099f5e8363aeb2c7baf6f7df42e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ebc14278592c483ab61c54fd66afcfd4de3f76b92cd5e4566f98b5b43311afc52414969125eff40de3c4b4ca0b9e48eab3855a37fed16e66e97ce8f2e5647986
|
|
7
|
+
data.tar.gz: d0b32ac7bd9b75d9d1b5868da6c14d757fb985fbc0f7c1d77ab0644785449e02a7adf595cff1d7ef94a663e2cb5bf12d422aa146b5ec1feb1e429290462cf69a
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -7,12 +7,18 @@ on:
|
|
|
7
7
|
jobs:
|
|
8
8
|
ci:
|
|
9
9
|
uses: LegionIO/.github/.github/workflows/ci.yml@main
|
|
10
|
+
with:
|
|
11
|
+
companion-gems: >-
|
|
12
|
+
{"lex-llm":{"repository":"LegionIO/lex-llm","ref":"eedf5172abe0bfda26501967c3f3f38b7c180095"}}
|
|
10
13
|
|
|
11
14
|
excluded-files:
|
|
12
15
|
uses: LegionIO/.github/.github/workflows/excluded-files.yml@main
|
|
13
16
|
|
|
14
17
|
security:
|
|
15
18
|
uses: LegionIO/.github/.github/workflows/security-scan.yml@main
|
|
19
|
+
with:
|
|
20
|
+
companion-gems: >-
|
|
21
|
+
{"lex-llm":{"repository":"LegionIO/lex-llm","ref":"eedf5172abe0bfda26501967c3f3f38b7c180095"}}
|
|
16
22
|
|
|
17
23
|
version-changelog:
|
|
18
24
|
uses: LegionIO/.github/.github/workflows/version-changelog.yml@main
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.8] - 2026-10-31
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Render URL images with `source.url` and base64 images with `source.data` through one translator-owned image mapping used by both callable and standalone translation.
|
|
7
|
+
- Preserve explicit text/image cache-control metadata, including TTL, in chat and streaming requests.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- Require `lex-llm >= 0.8.6` for canonical image source normalization.
|
|
11
|
+
|
|
3
12
|
## [0.3.7] - 2026-08-25
|
|
4
13
|
|
|
5
14
|
### Fixed
|
data/Gemfile
CHANGED
|
@@ -4,10 +4,10 @@ source 'https://rubygems.org'
|
|
|
4
4
|
|
|
5
5
|
gemspec
|
|
6
6
|
|
|
7
|
-
#
|
|
8
|
-
# 0.8.0 conformance work resolves against the local contract cut.
|
|
7
|
+
# Use immutable CI companions or adjacent development checkouts when available.
|
|
9
8
|
group :test do
|
|
10
|
-
lex_llm_path = File.expand_path('
|
|
9
|
+
lex_llm_path = File.expand_path('.ci-dependencies/lex-llm', __dir__)
|
|
10
|
+
lex_llm_path = File.expand_path('../lex-llm', __dir__) unless Dir.exist?(lex_llm_path)
|
|
11
11
|
gem 'lex-llm', path: lex_llm_path if Dir.exist?(lex_llm_path)
|
|
12
12
|
end
|
|
13
13
|
|
data/README.md
CHANGED
|
@@ -7,12 +7,17 @@ This gem provides the `:anthropic` provider family for LegionIO's LLM routing la
|
|
|
7
7
|
**Namespace:** `Legion::Extensions::Llm::Anthropic`
|
|
8
8
|
**Provider family:** `:anthropic`
|
|
9
9
|
**Default model:** `claude-sonnet-4-6`
|
|
10
|
-
**Dependency:** `lex-llm >= 0.
|
|
10
|
+
**Dependency:** `lex-llm >= 0.8.6` (shared Canonical, Inventory and exact fleet contracts)
|
|
11
11
|
|
|
12
12
|
```ruby
|
|
13
13
|
require 'legion/extensions/llm/anthropic'
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
Canonical URL images render as `source: { type: 'url', url: ... }`; base64 images
|
|
17
|
+
render as `source: { type: 'base64', media_type: ..., data: ... }`. The callable and
|
|
18
|
+
standalone translator share this mapping. Ordered text/image content and explicit
|
|
19
|
+
cache-control metadata, including TTL, survive chat, streaming and fleet rehydration.
|
|
20
|
+
|
|
16
21
|
---
|
|
17
22
|
|
|
18
23
|
## File Index
|
data/lex-llm-anthropic.gemspec
CHANGED
|
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
# 0.8.0 is the complete contract cut: Canonical is the only internal language,
|
|
31
31
|
# the legacy type set and the LegacyCoordinatorAdapter wiring are deleted, and
|
|
32
32
|
# the provider funnel enforces canonical messages centrally.
|
|
33
|
-
spec.add_dependency 'lex-llm', '>= 0.8.
|
|
33
|
+
spec.add_dependency 'lex-llm', '>= 0.8.6'
|
|
34
34
|
end
|
|
@@ -159,27 +159,22 @@ module Legion
|
|
|
159
159
|
# One canonical block to one Anthropic wire block; nil when the block
|
|
160
160
|
# renders nothing (an empty text block would 400 on the API).
|
|
161
161
|
def content_block_to_wire(block, cache: false)
|
|
162
|
-
case block.type
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
else
|
|
179
|
-
raise ArgumentError,
|
|
180
|
-
"anthropic provider cannot render content block type #{block.type.inspect} — " \
|
|
181
|
-
'only text, thinking, and image blocks cross this wire'
|
|
182
|
-
end
|
|
162
|
+
wire = case block.type
|
|
163
|
+
when :text
|
|
164
|
+
return nil if block.text.to_s.empty?
|
|
165
|
+
|
|
166
|
+
text_block(block.text, cache:)
|
|
167
|
+
when :thinking
|
|
168
|
+
thinking_block(block)
|
|
169
|
+
when :image
|
|
170
|
+
translator.render_image_block(block:)
|
|
171
|
+
else
|
|
172
|
+
raise ArgumentError,
|
|
173
|
+
"anthropic provider cannot render content block type #{block.type.inspect} — " \
|
|
174
|
+
'only text, thinking, and image blocks cross this wire'
|
|
175
|
+
end
|
|
176
|
+
wire[:cache_control] = block.cache_control if block.cache_control
|
|
177
|
+
wire
|
|
183
178
|
end
|
|
184
179
|
|
|
185
180
|
def text_block(text, cache: false)
|
|
@@ -91,6 +91,19 @@ module Legion
|
|
|
91
91
|
base.compact
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
+
# Shared by the callable render path and standalone request translation.
|
|
95
|
+
def render_image_block(block:)
|
|
96
|
+
source = case block.source_type
|
|
97
|
+
when :url
|
|
98
|
+
{ type: 'url', url: block.data }
|
|
99
|
+
when :base64
|
|
100
|
+
{ type: 'base64', media_type: block.media_type, data: block.data }
|
|
101
|
+
else
|
|
102
|
+
raise ArgumentError, "unsupported Anthropic image source type #{block.source_type.inspect}"
|
|
103
|
+
end
|
|
104
|
+
{ type: 'image', source: source }
|
|
105
|
+
end
|
|
106
|
+
|
|
94
107
|
# Parse: Anthropic wire Hash to Canonical::Response. Accepts both Anthropic wire format
|
|
95
108
|
# (content: array of blocks) and canonical form (text: string) for conformance kit compatibility.
|
|
96
109
|
def parse_response(wire)
|
|
@@ -269,8 +282,7 @@ module Legion
|
|
|
269
282
|
{ type: 'tool_result', tool_use_id: block.tool_use_id,
|
|
270
283
|
content: [{ type: 'text', text: block.text || '' }] }
|
|
271
284
|
when :image
|
|
272
|
-
|
|
273
|
-
media_type: block.media_type, data: block.data } }
|
|
285
|
+
render_image_block(block:)
|
|
274
286
|
else
|
|
275
287
|
{ type: 'text', text: block.text || '' }
|
|
276
288
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lex-llm-anthropic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LegionIO
|
|
@@ -71,14 +71,14 @@ dependencies:
|
|
|
71
71
|
requirements:
|
|
72
72
|
- - ">="
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: 0.8.
|
|
74
|
+
version: 0.8.6
|
|
75
75
|
type: :runtime
|
|
76
76
|
prerelease: false
|
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
79
|
- - ">="
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: 0.8.
|
|
81
|
+
version: 0.8.6
|
|
82
82
|
description: Anthropic provider integration for the LegionIO LLM routing framework.
|
|
83
83
|
email:
|
|
84
84
|
- matthewdiverson@gmail.com
|