omniai-anthropic 3.10.0 → 3.12.0
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/README.md +6 -0
- data/lib/omniai/anthropic/chat.rb +8 -5
- data/lib/omniai/anthropic/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: 07dc160091024eb4028a842392bbdf5921c74580217306b0610e0f347fda80b8
|
|
4
|
+
data.tar.gz: 0afd8a083a99409182777f74baf8ef128f60fc94b27650dda2b5dc10f3334c08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e18b6a471f4113af70d6c6dad210fd150d3502f68f812f7f30fd16f4cd30071dcf52bf2ae4dbfb0aec4d729e12dbc30e2fd76c4a13c9853bfe1ab6ac6b0dcb61
|
|
7
|
+
data.tar.gz: e41208c9d2904ec7a2f94af28ecb28547a827e6d34fbb5a6f0f31b5a56be284a28d893306cd8750d75f34ea0ac65012b707333701abc8cae9eb48fa48f3f09c5
|
data/README.md
CHANGED
|
@@ -180,6 +180,12 @@ client.chat(prompt, tools:, cache: true) # 5-minute TTL
|
|
|
180
180
|
client.chat(prompt, tools:, cache: { ttl: "1h" }) # 1-hour TTL
|
|
181
181
|
```
|
|
182
182
|
|
|
183
|
+
For single-shot prompts that share a system prompt but send a different message each time (e.g. one call per document), `cache: :system` marks only the system prompt (or the last tool), so the unique message is not written to the cache:
|
|
184
|
+
|
|
185
|
+
```ruby
|
|
186
|
+
client.chat(prompt, cache: :system) # 5-minute TTL
|
|
187
|
+
```
|
|
188
|
+
|
|
183
189
|
`usage.input_tokens` reports the whole prompt, including cached tokens. The cache breakdown is on each response's raw usage:
|
|
184
190
|
|
|
185
191
|
```ruby
|
|
@@ -41,6 +41,7 @@ module OmniAI
|
|
|
41
41
|
CLAUDE_SONNET_4_6_20260217 = "claude-sonnet-4-6-20260217"
|
|
42
42
|
|
|
43
43
|
CLAUDE_HAIKU_4_5 = "claude-haiku-4-5"
|
|
44
|
+
CLAUDE_HAIKU_5_5 = "claude-haiku-5-5"
|
|
44
45
|
CLAUDE_OPUS_4_0 = "claude-opus-4-0"
|
|
45
46
|
CLAUDE_OPUS_4_1 = "claude-opus-4-1"
|
|
46
47
|
CLAUDE_OPUS_4_5 = "claude-opus-4-5"
|
|
@@ -63,8 +64,8 @@ module OmniAI
|
|
|
63
64
|
DEFAULT_MODEL = Model::CLAUDE_SONNET
|
|
64
65
|
|
|
65
66
|
# Models that reject `temperature` with a 400 ("`temperature` is deprecated for this model"), even with
|
|
66
|
-
# thinking omitted. Every entry below was verified live against the API (
|
|
67
|
-
# 2026-09-26). Opus 4.8 rejects it too but has no constant yet.
|
|
67
|
+
# thinking omitted. Every entry below was verified live against the API (Haiku 5.5 on 2026-10-07, Sonnet 5.5 on
|
|
68
|
+
# 2026-09-28, the rest on 2026-09-26). Opus 4.8 rejects it too but has no constant yet.
|
|
68
69
|
#
|
|
69
70
|
# Models absent from this list pass `temperature` through unchanged. That is deliberate: an unlisted
|
|
70
71
|
# model that rejects it surfaces a loud API error the caller can act on, whereas over-applying the guard
|
|
@@ -75,6 +76,7 @@ module OmniAI
|
|
|
75
76
|
Model::CLAUDE_OPUS_5_5,
|
|
76
77
|
Model::CLAUDE_SONNET_5,
|
|
77
78
|
Model::CLAUDE_SONNET_5_5,
|
|
79
|
+
Model::CLAUDE_HAIKU_5_5,
|
|
78
80
|
].freeze
|
|
79
81
|
|
|
80
82
|
# @return [Context]
|
|
@@ -184,12 +186,12 @@ module OmniAI
|
|
|
184
186
|
end
|
|
185
187
|
|
|
186
188
|
# When caching, the last block of the last message is marked so each tool-loop round reads the history the
|
|
187
|
-
# previous round wrote.
|
|
189
|
+
# previous round wrote. `cache: :system` skips this for single-shot prompts whose message is never reused.
|
|
188
190
|
#
|
|
189
191
|
# @return [Array<Hash>]
|
|
190
192
|
def messages
|
|
191
193
|
messages = @prompt.messages.reject(&:system?).map { |message| message.serialize(context:) }
|
|
192
|
-
return messages unless cache_control && messages.any?
|
|
194
|
+
return messages unless cache_control && @options[:cache] != :system && messages.any?
|
|
193
195
|
|
|
194
196
|
*history, last = messages
|
|
195
197
|
history + [last.merge(content: with_cache_control(last[:content]))]
|
|
@@ -209,12 +211,13 @@ module OmniAI
|
|
|
209
211
|
|
|
210
212
|
# Translates the opt-in `cache` option to Anthropic's `cache_control`.
|
|
211
213
|
# Example: `cache: true` becomes `{ type: "ephemeral" }` (5-minute TTL)
|
|
214
|
+
# Example: `cache: :system` becomes `{ type: "ephemeral" }` on the system prompt (or last tool) only
|
|
212
215
|
# Example: `cache: { ttl: "1h" }` becomes `{ type: "ephemeral", ttl: "1h" }`
|
|
213
216
|
#
|
|
214
217
|
# @return [Hash, nil]
|
|
215
218
|
def cache_control
|
|
216
219
|
case @options[:cache]
|
|
217
|
-
when true then { type: "ephemeral" }
|
|
220
|
+
when true, :system then { type: "ephemeral" }
|
|
218
221
|
when Hash then { type: "ephemeral" }.merge(@options[:cache])
|
|
219
222
|
end
|
|
220
223
|
end
|