omniai-anthropic 3.5.0 → 3.6.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 70d172e3b288451b57742351a6db872672b84a7a9f0b139e2466299b17ef3a2e
|
|
4
|
+
data.tar.gz: b83fb955581badb868e95b99caee30d1b3e2aa9203a01bcd137b7b0517d14cf3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 26ef3bb07ec0aae3544ec8008a745d754a0a2044645836b26507b1be5c148c341877763281826a8745e5a93df6534032454d38b95d4b062a926875fb32b6e263
|
|
7
|
+
data.tar.gz: 10efb98acf0f9ee712568d4c1a4cf7087c32bbaae0ec82b28dec5d046937803595483df3a6039dd042c28653a346a8cdfb1866329ef149eb6feec831cfde8c63
|
|
@@ -81,10 +81,15 @@ module OmniAI
|
|
|
81
81
|
|
|
82
82
|
input_tokens = data.dig("usage", "input_tokens")
|
|
83
83
|
output_tokens = data.dig("usage", "output_tokens")
|
|
84
|
+
# The thinking breakdown arrives only on the final `message_delta`. Carrying it through keeps streamed
|
|
85
|
+
# responses reporting the same `thinking_tokens` as non-streamed ones; without it the key is dropped and
|
|
86
|
+
# every streamed response silently reports no reasoning.
|
|
87
|
+
output_tokens_details = data.dig("usage", "output_tokens_details")
|
|
84
88
|
|
|
85
89
|
@data["usage"] ||= {}
|
|
86
90
|
@data["usage"]["input_tokens"] = input_tokens if input_tokens
|
|
87
91
|
@data["usage"]["output_tokens"] = output_tokens if output_tokens
|
|
92
|
+
@data["usage"]["output_tokens_details"] = output_tokens_details if output_tokens_details
|
|
88
93
|
end
|
|
89
94
|
|
|
90
95
|
# Handler for Type::MESSAGE_STOP
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OmniAI
|
|
4
|
+
module Anthropic
|
|
5
|
+
class Chat
|
|
6
|
+
# Overrides usage deserialize to read Anthropic's reasoning breakdown.
|
|
7
|
+
module UsageSerializer
|
|
8
|
+
# Anthropic already counts reasoning inside `output_tokens` and reports the breakdown alongside it at
|
|
9
|
+
# `output_tokens_details.thinking_tokens`, so the breakdown is read into `thinking_tokens` and the output
|
|
10
|
+
# count is left exactly as reported. Adding the two together would double count.
|
|
11
|
+
#
|
|
12
|
+
# When streaming, the breakdown arrives only on the final `message_delta`.
|
|
13
|
+
#
|
|
14
|
+
# @param data [Hash]
|
|
15
|
+
# @return [OmniAI::Chat::Usage]
|
|
16
|
+
def self.deserialize(data, *)
|
|
17
|
+
# Deserialize without a context so the generic flat parse runs rather than recursing into this method.
|
|
18
|
+
usage = OmniAI::Chat::Usage.deserialize(data)
|
|
19
|
+
|
|
20
|
+
# Only overwrite when the vendor container is actually present. A payload produced by `Usage#serialize`
|
|
21
|
+
# carries base's own `thinking_tokens` key and no `output_tokens_details`, so assigning unconditionally
|
|
22
|
+
# would clobber a correctly-parsed value with nil and break the round-trip. `unless nil?` rather than
|
|
23
|
+
# `||=`, so a reported zero from the wire still wins over base's nil.
|
|
24
|
+
thinking_tokens = data.dig("output_tokens_details", "thinking_tokens")
|
|
25
|
+
usage.thinking_tokens = thinking_tokens unless thinking_tokens.nil?
|
|
26
|
+
|
|
27
|
+
usage
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -87,6 +87,8 @@ module OmniAI
|
|
|
87
87
|
|
|
88
88
|
context.serializers[:thinking] = ThinkingSerializer.method(:serialize)
|
|
89
89
|
context.deserializers[:thinking] = ThinkingSerializer.method(:deserialize)
|
|
90
|
+
|
|
91
|
+
context.deserializers[:usage] = UsageSerializer.method(:deserialize)
|
|
90
92
|
end
|
|
91
93
|
|
|
92
94
|
# @return [Hash]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omniai-anthropic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kevin Sylvestre
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '3.
|
|
32
|
+
version: '3.8'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '3.
|
|
39
|
+
version: '3.8'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: openssl
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -89,6 +89,7 @@ files:
|
|
|
89
89
|
- lib/omniai/anthropic/chat/tool_call_serializer.rb
|
|
90
90
|
- lib/omniai/anthropic/chat/tool_serializer.rb
|
|
91
91
|
- lib/omniai/anthropic/chat/url_serializer.rb
|
|
92
|
+
- lib/omniai/anthropic/chat/usage_serializer.rb
|
|
92
93
|
- lib/omniai/anthropic/client.rb
|
|
93
94
|
- lib/omniai/anthropic/computer.rb
|
|
94
95
|
- lib/omniai/anthropic/config.rb
|