lex-llm-bedrock 0.3.11 → 0.3.12
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 939ac50e6240dcde55f7bc9b24fb0a7f1f6fd527ec46cea27d8255f8a401fcd6
|
|
4
|
+
data.tar.gz: 899da50daa4595d92b0bb23a14bd4c873c03d41bc72235e8337b17f61fe69d99
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b2e824ee11517dbbfaf7710bd25a8329ee9007ccb35226776a57131d4ba859fc90fc2b8f0dc3e31ff349b2cc15e3a82778e491fca0f75b2b76d6a4783a8e7e67
|
|
7
|
+
data.tar.gz: c06248c9b3c047db80193c7a3c9666b0b251de5bb6a62199f135902f91295cfcfc069e2994cdc93168b66a1c11a7ad755875bc1c9ba8fd60ae0850a7277dae30
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.12 - 2026-06-02
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **ContentBlock union validation errors** — Removed `cache_control` from text blocks, system blocks, and tool definitions. The Bedrock Converse SDK's `ContentBlock` is a strict union (text|image|tool_use|...); adding `cache_control` as a sibling key triggered "multiple values provided to union" and "unexpected value" ArgumentError (provider.rb)
|
|
7
|
+
- **Assistant tool_call messages rejected by SDK** — Messages with tool calls were sent as raw content blocks with `:type`/`:content` keys. Now emits proper `{ tool_use: { tool_use_id, name, input } }` blocks via new `build_content_blocks`/`assistant_tool_use_blocks` methods (provider.rb)
|
|
8
|
+
- **PROMPT-CACHE-01 reverted** — Bedrock Converse API does not support `cache_control` on text/document/image blocks. The markers added in 0.3.11 are removed (provider.rb)
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Per-provider discovery refresh actor** — New `actors/discovery_refresh.rb` that only refreshes Bedrock models, avoiding coupling to other providers' discovery cycles
|
|
12
|
+
|
|
3
13
|
## 0.3.11 - 2026-05-31
|
|
4
14
|
|
|
5
15
|
### Security
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
begin
|
|
4
|
+
require 'legion/extensions/actors/every'
|
|
5
|
+
rescue LoadError => e
|
|
6
|
+
warn(e.message) if $VERBOSE
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
return unless defined?(Legion::Extensions::Actors::Every)
|
|
10
|
+
|
|
11
|
+
module Legion
|
|
12
|
+
module Extensions
|
|
13
|
+
module Llm
|
|
14
|
+
module Bedrock
|
|
15
|
+
module Actor
|
|
16
|
+
class DiscoveryRefresh < Legion::Extensions::Actors::Every # rubocop:disable Style/Documentation
|
|
17
|
+
include Legion::Logging::Helper
|
|
18
|
+
|
|
19
|
+
REFRESH_INTERVAL = 1800
|
|
20
|
+
|
|
21
|
+
def runner_class = self.class
|
|
22
|
+
def runner_function = 'manual'
|
|
23
|
+
def run_now? = true
|
|
24
|
+
def use_runner? = false
|
|
25
|
+
def check_subtask? = false
|
|
26
|
+
def generate_task? = false
|
|
27
|
+
|
|
28
|
+
def time
|
|
29
|
+
return REFRESH_INTERVAL unless defined?(Legion::Settings)
|
|
30
|
+
|
|
31
|
+
Legion::Settings.dig(:extensions, :llm, :bedrock, :discovery_interval) || REFRESH_INTERVAL
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def manual
|
|
35
|
+
log.debug('[bedrock][discovery_refresh] refreshing model list')
|
|
36
|
+
return unless defined?(Legion::LLM::Discovery)
|
|
37
|
+
|
|
38
|
+
Legion::LLM::Discovery.refresh_discovered_models!(provider: :bedrock)
|
|
39
|
+
rescue StandardError => e
|
|
40
|
+
handle_exception(e, level: :warn, handled: true, operation: 'bedrock.actor.discovery_refresh')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -377,7 +377,7 @@ module Legion
|
|
|
377
377
|
def format_messages(messages)
|
|
378
378
|
total = messages.size
|
|
379
379
|
messages.filter_map.with_index do |message, idx|
|
|
380
|
-
blocks =
|
|
380
|
+
blocks = build_content_blocks(message)
|
|
381
381
|
next if blocks.empty?
|
|
382
382
|
|
|
383
383
|
cache_blocks = should_cache_message?(idx, total) ? add_cache_control_to_blocks(blocks) : blocks
|
|
@@ -403,9 +403,10 @@ module Legion
|
|
|
403
403
|
end
|
|
404
404
|
|
|
405
405
|
def add_cache_control_to_blocks(blocks)
|
|
406
|
-
blocks.
|
|
407
|
-
|
|
408
|
-
|
|
406
|
+
# Bedrock Converse API does not support cache_control on text/image/document blocks.
|
|
407
|
+
# Only tool_use blocks support it via the InputMember cache_control field.
|
|
408
|
+
# Return blocks unchanged to avoid SDK union validation errors.
|
|
409
|
+
blocks
|
|
409
410
|
end
|
|
410
411
|
|
|
411
412
|
def format_system(messages)
|
|
@@ -417,13 +418,39 @@ module Legion
|
|
|
417
418
|
def system_blocks(system)
|
|
418
419
|
return nil if system.to_s.empty?
|
|
419
420
|
|
|
420
|
-
[{ text: system
|
|
421
|
+
[{ text: system }]
|
|
421
422
|
end
|
|
422
423
|
|
|
423
424
|
def bedrock_role(role)
|
|
424
425
|
role == :assistant ? 'assistant' : 'user'
|
|
425
426
|
end
|
|
426
427
|
|
|
428
|
+
def build_content_blocks(message)
|
|
429
|
+
return tool_result_blocks(message) if message.role == :tool
|
|
430
|
+
|
|
431
|
+
# Assistant messages with tool calls: build text + tool_use blocks
|
|
432
|
+
return assistant_tool_use_blocks(message) if message.role == :assistant && message.tool_call?
|
|
433
|
+
|
|
434
|
+
content_blocks(message.content)
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
def assistant_tool_use_blocks(message)
|
|
438
|
+
blocks = []
|
|
439
|
+
text = content_text(message.content)
|
|
440
|
+
blocks << { text: text } if text && !text.strip.empty?
|
|
441
|
+
|
|
442
|
+
message.tool_calls.each do |call|
|
|
443
|
+
blocks << {
|
|
444
|
+
tool_use: {
|
|
445
|
+
tool_use_id: call.id,
|
|
446
|
+
name: call.name,
|
|
447
|
+
input: call.arguments || {}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
end
|
|
451
|
+
blocks
|
|
452
|
+
end
|
|
453
|
+
|
|
427
454
|
def content_blocks(content)
|
|
428
455
|
raw = raw_content(content)
|
|
429
456
|
return raw if raw
|
|
@@ -493,7 +520,7 @@ module Legion
|
|
|
493
520
|
end
|
|
494
521
|
|
|
495
522
|
def tool_definition_with_cache(tool)
|
|
496
|
-
tool_definition(tool)
|
|
523
|
+
tool_definition(tool)
|
|
497
524
|
end
|
|
498
525
|
|
|
499
526
|
def tool_definition(tool)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lex-llm-bedrock
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LegionIO
|
|
@@ -125,6 +125,7 @@ files:
|
|
|
125
125
|
- README.md
|
|
126
126
|
- lex-llm-bedrock.gemspec
|
|
127
127
|
- lib/legion/extensions/llm/bedrock.rb
|
|
128
|
+
- lib/legion/extensions/llm/bedrock/actors/discovery_refresh.rb
|
|
128
129
|
- lib/legion/extensions/llm/bedrock/actors/fleet_worker.rb
|
|
129
130
|
- lib/legion/extensions/llm/bedrock/provider.rb
|
|
130
131
|
- lib/legion/extensions/llm/bedrock/runners/fleet_worker.rb
|