ruby_llm-bedrock_invoke 0.1.0.pre.1 → 0.1.0.pre.2
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/lib/ruby_llm/bedrock_invoke/tool_search.rb +17 -0
- data/lib/ruby_llm/bedrock_invoke/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2f11b9070aa14278c81991a58dfb1cf31c6a7c500db12d4c0396587a668c1185
|
|
4
|
+
data.tar.gz: 164e91d6fe0957ee43122ca891b3652110f5ecf795d21eb51d19881904b28968
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 73fee9053d1ff92e1cf064743f0462e1c1a1daa8361d94d71b09ddc186ec484c9e8d67af67554a75cce61306c4e55e6cc3460b248e378c8eece94b1320a5d73d
|
|
7
|
+
data.tar.gz: 48721d75269e23c872208d6edb39613cdd98c68fbe5700e2f7171a1162a9dc0c06b0ce470af008c3ae07de2dcdc84308143c09d1c85cdd2bf17a040524106960
|
|
@@ -51,10 +51,27 @@ module RubyLLM
|
|
|
51
51
|
return payload unless definitions.any? { |d| deferred_definition?(d) }
|
|
52
52
|
|
|
53
53
|
inject_search_tool!(definitions)
|
|
54
|
+
mark_cache_breakpoint!(definitions)
|
|
54
55
|
payload[:anthropic_beta] = Array(payload[:anthropic_beta]) | [BETA_FLAG]
|
|
55
56
|
payload
|
|
56
57
|
end
|
|
57
58
|
|
|
59
|
+
# Cache the eager (non-deferred) tool-definitions prefix. Deferred tools
|
|
60
|
+
# can't carry cache_control (the API returns 400) and are excluded from the
|
|
61
|
+
# cached prefix anyway, so the breakpoint goes on the last NON-deferred
|
|
62
|
+
# tool. This preserves prompt caching across turns (the discovered tools
|
|
63
|
+
# load inline as tool_reference blocks, never touching this prefix) and,
|
|
64
|
+
# crucially, gives the request the >=1 cache_control marker that turns on
|
|
65
|
+
# the API's automatic caching of server tool-search results.
|
|
66
|
+
def mark_cache_breakpoint!(definitions)
|
|
67
|
+
return if definitions.any? { |d| d.is_a?(Hash) && definition_value(d, :cache_control) }
|
|
68
|
+
|
|
69
|
+
last_eager = definitions.reverse.find { |d| d.is_a?(Hash) && !deferred_definition?(d) }
|
|
70
|
+
return unless last_eager
|
|
71
|
+
|
|
72
|
+
last_eager[:cache_control] = { type: 'ephemeral' }
|
|
73
|
+
end
|
|
74
|
+
|
|
58
75
|
# Both generations deep-merge user params (with_params /
|
|
59
76
|
# with_provider_options) over the rendered payload AFTER apply! runs,
|
|
60
77
|
# and deep_merge REPLACES arrays — silently dropping the beta flag.
|