lex-llm-anthropic 0.2.9 → 0.2.11

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: d7687ad53b9f3aa50db888d664f8ac8e1dbdd92bac3701097b1aa40312a30ff9
4
- data.tar.gz: 1eaf4a5fdd3f40a27da9fb72983fafab2dd974f81e40ed1d0e73a0d82d4fec47
3
+ metadata.gz: 1237cef4710e768a52ab02e062379ed70a6f2ee7456cca1b5a45cfb03489c5c4
4
+ data.tar.gz: bb9a132592136f7c64c4f982a6d1f9896348e0362da9d46d77fb846566b6a2d8
5
5
  SHA512:
6
- metadata.gz: 8f44ddddc7211f40bd5e155d802c1b59983ebbd0fe4ed2db3f1e6e9e637dce9c4d9428a2fdf59a3190f59cba71ac9443448d2c488ceac213bda8d453d06bf1e2
7
- data.tar.gz: 979bcf878d565712f1d24a32aaeedb24f7311c05b36a82861c547dc1f37931b97f2bd997a17f5507ba91d77b27ba7f3a9cc658d6ecc81c98f6e6573b324da527
6
+ metadata.gz: 9e138f44cbb23a70c48dc489e53bc6dff5fef7964db248b41f519b37a71e839dee7aa2dcbc26ce7cc5aa41e3df5720c0889537c497b6fb25bfb31053864d0066
7
+ data.tar.gz: 725a59b156f68280cbc9d276eccb6c90e21c638900dbf6d81405588a15bd0ce00c3413555c311aef411162669b959635e9f3d4363fcd124d364eedf8725ef189
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.11 - 2026-05-21
4
+
5
+ - Add `api_version` and `default_max_tokens` to default_settings
6
+ - api_base and anthropic-version read from settings fallback
7
+ - max_tokens reads from settings[:default_max_tokens]
8
+ - Identity headers included via base provider
9
+
10
+
11
+ ## 0.2.10 - 2026-05-18
12
+
13
+ - Fix streaming tool call input accumulation: `build_chunk` now handles both `content_block_start` (tool_use with id+name) and `input_json_delta` (partial argument fragments) events. Previously only the start event was parsed, resulting in tool calls with empty arguments.
14
+
15
+
3
16
  ## 0.2.9 - 2026-05-16
4
17
 
5
18
  - Advertise Anthropic tool support in discovered instance and model metadata so capability-aware routing can select Claude models for native tool requests.
@@ -35,15 +35,19 @@ module Legion
35
35
  def embeddings?(_model) = false
36
36
  end
37
37
 
38
+ def settings
39
+ Anthropic.default_settings
40
+ end
41
+
38
42
  def api_base
39
- config.anthropic_api_base || 'https://api.anthropic.com'
43
+ config.anthropic_api_base || settings[:endpoint] || 'https://api.anthropic.com'
40
44
  end
41
45
 
42
46
  def headers
43
- {
47
+ identity_headers.merge({
44
48
  'x-api-key' => config.anthropic_api_key,
45
- 'anthropic-version' => config.anthropic_version || '2023-06-01'
46
- }.compact
49
+ 'anthropic-version' => config.anthropic_version || settings[:api_version] || '2023-06-01'
50
+ }.compact)
47
51
  end
48
52
 
49
53
  def completion_url = '/v1/messages'
@@ -82,7 +86,7 @@ module Legion
82
86
  model: model.id,
83
87
  messages: format_messages(chat_messages, thinking: thinking_enabled?(thinking)),
84
88
  stream: stream,
85
- max_tokens: model.max_tokens || 4096,
89
+ max_tokens: model.max_tokens || settings[:default_max_tokens] || 4096,
86
90
  system: system_content(system_messages),
87
91
  thinking: thinking_payload(thinking),
88
92
  temperature: temperature,
@@ -347,10 +351,24 @@ module Legion
347
351
  ),
348
352
  input_tokens: data.dig('message', 'usage', 'input_tokens'),
349
353
  output_tokens: data.dig('message', 'usage', 'output_tokens') || data.dig('usage', 'output_tokens'),
350
- tool_calls: parse_tool_calls(data['content_block'])
354
+ tool_calls: extract_streaming_tool_calls(data, delta_type)
351
355
  )
352
356
  end
353
357
 
358
+ def extract_streaming_tool_calls(data, delta_type)
359
+ content_block = data['content_block']
360
+ if content_block && content_block['type'] == 'tool_use'
361
+ { content_block['id'] => Legion::Extensions::Llm::ToolCall.new(
362
+ id: content_block['id'], name: content_block['name'], arguments: ''
363
+ ) }
364
+ elsif delta_type == 'input_json_delta'
365
+ partial = data.dig('delta', 'partial_json')
366
+ return nil unless partial
367
+
368
+ { nil => Legion::Extensions::Llm::ToolCall.new(id: nil, name: nil, arguments: partial) }
369
+ end
370
+ end
371
+
354
372
  def parse_tool_calls(content_blocks)
355
373
  blocks = Array(content_blocks).select { |block| block && block['type'] == 'tool_use' }
356
374
  return nil if blocks.empty?
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Llm
6
6
  module Anthropic
7
- VERSION = '0.2.9'
7
+ VERSION = '0.2.11'
8
8
  end
9
9
  end
10
10
  end
@@ -24,6 +24,8 @@ module Legion
24
24
  instance: {
25
25
  default_model: 'claude-sonnet-4-6',
26
26
  endpoint: 'https://api.anthropic.com',
27
+ api_version: '2023-06-01',
28
+ default_max_tokens: 4096,
27
29
  tier: :frontier,
28
30
  transport: :http,
29
31
  credentials: { api_key: 'env://ANTHROPIC_API_KEY' },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-llm-anthropic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - LegionIO