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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1237cef4710e768a52ab02e062379ed70a6f2ee7456cca1b5a45cfb03489c5c4
|
|
4
|
+
data.tar.gz: bb9a132592136f7c64c4f982a6d1f9896348e0362da9d46d77fb846566b6a2d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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:
|
|
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?
|
|
@@ -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' },
|