omniai-anthropic 3.2.1 → 3.4.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: acf0d7364e586047dfdad9d4e48892ceaaf18b641e7f9bdcbd43a383c03de6bb
4
- data.tar.gz: cf134c06b43d88c1e407e4a86a6c5846e9a5322b8b00c9fd8499d1e47f0da74a
3
+ metadata.gz: 51038af19ea0a13387faed14b0cbd42b43c4f3d82430665cfe168813295982f9
4
+ data.tar.gz: 3cd1e182f591fd31dba7ac1232e662d04f740280a63ab968cb9df9d1458e2d03
5
5
  SHA512:
6
- metadata.gz: 7322cdbda4727494805ffe2d7dd9593bd21e6d828188b95a767a1194413df9a9cff86fdde3390490fceb7085f1c295ddbc8195c337edb0ad601f1b1cd13c357a
7
- data.tar.gz: ca7fa497bba5bbf194e1b2d254700ef94498e4b2be7b0ef1ca64e2b6cd1c8b0ad1bc7f45f28a68f46a1edde38ad2ee68ee9f92b6b986cb16abc63974dfd9dc1f
6
+ metadata.gz: 7cee7fb0473b28cd507241338c1635fcc5cb99ccb24b8756dd9629d6c7b1a2a5362fcbb9029830bd5b465fd336416c9f0877b479094f1bc8559cc3881ce3a5c0
7
+ data.tar.gz: 39617ae4f969636eaa3163a4a5c065729684dec4213b07f936869efc3d37112073088901db338e5f2d611f153f5434ab2eacda9cb32ecf70bbf9f8e5415c9aa5
data/README.md CHANGED
@@ -61,7 +61,7 @@ completion.text # 'The capital of Canada is Ottawa.'
61
61
 
62
62
  #### Model
63
63
 
64
- `model` takes an optional string (default is `claude-sonnet-4-6`):
64
+ `model` takes an optional string (default is `claude-sonnet-5`):
65
65
 
66
66
  ```ruby
67
67
  completion = client.chat('Provide code for fibonacci', model: OmniAI::Anthropic::Chat::Model::CLAUDE_SONNET)
@@ -5,6 +5,16 @@ module OmniAI
5
5
  class Chat
6
6
  # Overrides choice serialize / deserialize.
7
7
  module ChoiceSerializer
8
+ # Maps Anthropic `stop_reason` values onto the normalized OmniAI::Chat::FinishReason symbols. `pause_turn`
9
+ # is intentionally absent (a continuation signal, neither a stop nor a filter) — it falls through to `:other`.
10
+ FINISH_REASONS = {
11
+ "end_turn" => OmniAI::Chat::FinishReason::STOP,
12
+ "stop_sequence" => OmniAI::Chat::FinishReason::STOP,
13
+ "max_tokens" => OmniAI::Chat::FinishReason::LENGTH,
14
+ "tool_use" => OmniAI::Chat::FinishReason::TOOL_CALL,
15
+ "refusal" => OmniAI::Chat::FinishReason::FILTER,
16
+ }.freeze
17
+
8
18
  # @param choice [OmniAI::Chat::Choice]
9
19
  # @param context [Context]
10
20
  # @return [Hash]
@@ -17,7 +27,8 @@ module OmniAI
17
27
  # @return [OmniAI::Chat::Choice]
18
28
  def self.deserialize(data, context:)
19
29
  message = OmniAI::Chat::Message.deserialize(data, context:)
20
- OmniAI::Chat::Choice.new(message:)
30
+ finish_reason = OmniAI::Chat::FinishReason.deserialize(data["stop_reason"], table: FINISH_REASONS)
31
+ OmniAI::Chat::Choice.new(message:, finish_reason:)
21
32
  end
22
33
  end
23
34
  end
@@ -33,8 +33,7 @@ module OmniAI
33
33
  ContentSerializer.deserialize(content, context:)
34
34
  end
35
35
 
36
- tool_call_parts = parts.select { |part| part.is_a?(OmniAI::Chat::ToolCall) }
37
- non_tool_call_parts = parts.reject { |part| part.is_a?(OmniAI::Chat::ToolCall) }
36
+ tool_call_parts, non_tool_call_parts = parts.partition { |part| part.is_a?(OmniAI::Chat::ToolCall) }
38
37
 
39
38
  tool_call_list = OmniAI::Chat::ToolCallList.new(entries: tool_call_parts) if tool_call_parts.any?
40
39
  content = non_tool_call_parts if non_tool_call_parts.any?
@@ -49,10 +49,11 @@ module OmniAI
49
49
  CLAUDE_SONNET_4_0 = "claude-sonnet-4-0"
50
50
  CLAUDE_SONNET_4_5 = "claude-sonnet-4-5"
51
51
  CLAUDE_SONNET_4_6 = "claude-sonnet-4-6"
52
+ CLAUDE_SONNET_5 = "claude-sonnet-5"
52
53
 
53
54
  CLAUDE_HAIKU = CLAUDE_HAIKU_4_5
54
55
  CLAUDE_OPUS = CLAUDE_OPUS_4_7
55
- CLAUDE_SONNET = CLAUDE_SONNET_4_6
56
+ CLAUDE_SONNET = CLAUDE_SONNET_5
56
57
  end
57
58
 
58
59
  DEFAULT_MODEL = Model::CLAUDE_SONNET
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Anthropic
5
- VERSION = "3.2.1"
5
+ VERSION = "3.4.0"
6
6
  end
7
7
  end
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.2.1
4
+ version: 3.4.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.0'
32
+ version: '3.7'
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.0'
39
+ version: '3.7'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: openssl
42
42
  requirement: !ruby/object:Gem::Requirement