omniai-anthropic 3.11.0 → 3.13.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 +12 -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: 5500265ac9ff5fd7b3412587c7d7b1e68b74af45688d5f8496c6073d1407650c
|
|
4
|
+
data.tar.gz: 383ebf97f68953c636335d8737941a82ebb8eadf1b74f849a210d988400c8011
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 235e20cd9a9a0959ecbe88485b31b3cbaff1e743be7d5a11bfd98b16afdfad18f3b96573fa6b5c1e74589562229d13557ef3006994ecac5834ac4d65f4094c79
|
|
7
|
+
data.tar.gz: f929efb5fc878bcc97ed89844ab535b365f3885f7a91089de042f667ebf40db48a45fb0a11714c6d04bce7fc91bd1a915ad0bd2bfbcb5f9b151f5b4b3f82d428
|
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
|
|
@@ -47,6 +47,7 @@ module OmniAI
|
|
|
47
47
|
CLAUDE_OPUS_4_5 = "claude-opus-4-5"
|
|
48
48
|
CLAUDE_OPUS_4_6 = "claude-opus-4-6"
|
|
49
49
|
CLAUDE_OPUS_4_7 = "claude-opus-4-7"
|
|
50
|
+
CLAUDE_OPUS_4_8 = "claude-opus-4-8"
|
|
50
51
|
CLAUDE_OPUS_5 = "claude-opus-5"
|
|
51
52
|
CLAUDE_OPUS_5_5 = "claude-opus-5-5"
|
|
52
53
|
CLAUDE_SONNET_4_0 = "claude-sonnet-4-0"
|
|
@@ -55,6 +56,8 @@ module OmniAI
|
|
|
55
56
|
CLAUDE_SONNET_5 = "claude-sonnet-5"
|
|
56
57
|
CLAUDE_SONNET_5_5 = "claude-sonnet-5-5"
|
|
57
58
|
CLAUDE_FABLE_5 = "claude-fable-5"
|
|
59
|
+
CLAUDE_FABLE_5_1 = "claude-fable-5-1"
|
|
60
|
+
CLAUDE_FABLE_5_2 = "claude-fable-5-2"
|
|
58
61
|
|
|
59
62
|
CLAUDE_HAIKU = CLAUDE_HAIKU_4_5
|
|
60
63
|
CLAUDE_OPUS = CLAUDE_OPUS_5_5
|
|
@@ -64,19 +67,22 @@ module OmniAI
|
|
|
64
67
|
DEFAULT_MODEL = Model::CLAUDE_SONNET
|
|
65
68
|
|
|
66
69
|
# Models that reject `temperature` with a 400 ("`temperature` is deprecated for this model"), even with
|
|
67
|
-
# thinking omitted. Every entry below was verified live against the API (
|
|
68
|
-
# 2026-09-28, the rest on 2026-09-26).
|
|
70
|
+
# thinking omitted. Every entry below was verified live against the API (Opus 4.8 and Fable 5.1/5.2 on 2026-11-12,
|
|
71
|
+
# Haiku 5.5 on 2026-10-07, Sonnet 5.5 on 2026-09-28, the rest on 2026-09-26).
|
|
69
72
|
#
|
|
70
73
|
# Models absent from this list pass `temperature` through unchanged. That is deliberate: an unlisted
|
|
71
74
|
# model that rejects it surfaces a loud API error the caller can act on, whereas over-applying the guard
|
|
72
75
|
# would silently discard a caller's temperature.
|
|
73
76
|
TEMPERATURE_UNSUPPORTED_MODELS = [
|
|
74
77
|
Model::CLAUDE_OPUS_4_7,
|
|
78
|
+
Model::CLAUDE_OPUS_4_8,
|
|
75
79
|
Model::CLAUDE_OPUS_5,
|
|
76
80
|
Model::CLAUDE_OPUS_5_5,
|
|
77
81
|
Model::CLAUDE_SONNET_5,
|
|
78
82
|
Model::CLAUDE_SONNET_5_5,
|
|
79
83
|
Model::CLAUDE_HAIKU_5_5,
|
|
84
|
+
Model::CLAUDE_FABLE_5_1,
|
|
85
|
+
Model::CLAUDE_FABLE_5_2,
|
|
80
86
|
].freeze
|
|
81
87
|
|
|
82
88
|
# @return [Context]
|
|
@@ -186,12 +192,12 @@ module OmniAI
|
|
|
186
192
|
end
|
|
187
193
|
|
|
188
194
|
# When caching, the last block of the last message is marked so each tool-loop round reads the history the
|
|
189
|
-
# previous round wrote.
|
|
195
|
+
# previous round wrote. `cache: :system` skips this for single-shot prompts whose message is never reused.
|
|
190
196
|
#
|
|
191
197
|
# @return [Array<Hash>]
|
|
192
198
|
def messages
|
|
193
199
|
messages = @prompt.messages.reject(&:system?).map { |message| message.serialize(context:) }
|
|
194
|
-
return messages unless cache_control && messages.any?
|
|
200
|
+
return messages unless cache_control && @options[:cache] != :system && messages.any?
|
|
195
201
|
|
|
196
202
|
*history, last = messages
|
|
197
203
|
history + [last.merge(content: with_cache_control(last[:content]))]
|
|
@@ -211,12 +217,13 @@ module OmniAI
|
|
|
211
217
|
|
|
212
218
|
# Translates the opt-in `cache` option to Anthropic's `cache_control`.
|
|
213
219
|
# Example: `cache: true` becomes `{ type: "ephemeral" }` (5-minute TTL)
|
|
220
|
+
# Example: `cache: :system` becomes `{ type: "ephemeral" }` on the system prompt (or last tool) only
|
|
214
221
|
# Example: `cache: { ttl: "1h" }` becomes `{ type: "ephemeral", ttl: "1h" }`
|
|
215
222
|
#
|
|
216
223
|
# @return [Hash, nil]
|
|
217
224
|
def cache_control
|
|
218
225
|
case @options[:cache]
|
|
219
|
-
when true then { type: "ephemeral" }
|
|
226
|
+
when true, :system then { type: "ephemeral" }
|
|
220
227
|
when Hash then { type: "ephemeral" }.merge(@options[:cache])
|
|
221
228
|
end
|
|
222
229
|
end
|