lex-llm-anthropic 0.2.7 → 0.2.8

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: 706b82cf938d0f347b19db1fbf2f1e66ff0a1fc2c0029c20ba0696b14463bf16
4
- data.tar.gz: addcd78f5164cef165a316369f69fc6e8cabbd0e338f0a2c7bb6daacc8638392
3
+ metadata.gz: 23d189a1ea15ce64735d14d88766fcb6717136b9734c393599a7fbd3c7544b54
4
+ data.tar.gz: 5c3153468a9753fc406e5229ee41036113b5c396eb0b5761f933c2c8a78fba91
5
5
  SHA512:
6
- metadata.gz: 51a06c3a1c8e14435677f4ca79a7f8adadbcf497c7228ace93d7e6afaa1d2ae9d8796a0d36594ed8b8aa966e9ec85716a25da20a1ef80388527e7fcc944e3955
7
- data.tar.gz: 58d3e043cc3f82a0982198a70535c321681236e637832c437674d54f9247449743f4a92519e4df562a54db5466267a8269351a9f9d2f493214f65a0f74440981
6
+ metadata.gz: 97685da785d9c89c5b63cb64406c3487f12b943aa28b289ef553de7ca32ab3e454ef51f8cff9ad0af4762fadd760453899e64f902a79579d652c2ee045ce0b8f
7
+ data.tar.gz: 796d40a66a89b96ac401beb3b74237a09c7bfb2fa26819e589c937adfc771cc40051338899dc19c80204006a351fd0a7886af1524f74d7b507bbb1d8e0e6836a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.8 - 2026-05-13
4
+
5
+ - Remove `:claude` provider alias (`provider_aliases` now returns `[]`).
6
+ - Attach `source` and `credential_fingerprint` to all discovered instances.
7
+ - Inject `default_model: 'claude-sonnet-4-6'` and `capabilities: [:completion, :streaming, :vision]` into every discovered instance.
8
+ - Add static `CONTEXT_WINDOWS` map for known Claude model families.
9
+ - Override `fetch_model_detail` to return context window from static map.
10
+ - Use `model_detail` in `parse_list_models_response` for cached `context_length` lookup.
11
+ - Add `infer_context_window` helper for prefix-based context window inference.
12
+
3
13
  ## 0.2.7 - 2026-05-13
4
14
 
5
15
  - Use `Legion::Logging::Helper` for Anthropic provider and registry diagnostics.
@@ -62,6 +62,16 @@ module Legion
62
62
  end
63
63
  end
64
64
 
65
+ CONTEXT_WINDOWS = {
66
+ 'claude-opus-4' => 200_000,
67
+ 'claude-sonnet-4' => 200_000,
68
+ 'claude-haiku-4' => 200_000,
69
+ 'claude-3-5' => 200_000,
70
+ 'claude-3-opus' => 200_000,
71
+ 'claude-3-sonnet' => 200_000,
72
+ 'claude-3-haiku' => 200_000
73
+ }.freeze
74
+
65
75
  private
66
76
 
67
77
  def render_payload(messages, tools:, temperature:, model:, stream:, schema:, thinking:, tool_prefs:) # rubocop:disable Metrics/ParameterLists
@@ -360,14 +370,26 @@ module Legion
360
370
  def parse_list_models_response(response, provider, _capabilities)
361
371
  Array(response.body['data']).map do |model|
362
372
  model_id = model.fetch('id')
373
+ detail = model_detail(model_id)
374
+ ctx = detail&.dig(:context_window) || infer_context_window(model_id)
363
375
  Legion::Extensions::Llm::Model::Info.new(
364
376
  id: model_id,
365
377
  name: model['display_name'] || model_id,
366
378
  provider: provider,
379
+ context_length: ctx,
367
380
  metadata: model.merge('created_at' => model['created_at']).compact
368
381
  )
369
382
  end
370
383
  end
384
+
385
+ def infer_context_window(model_id)
386
+ CONTEXT_WINDOWS.find { |prefix, _| model_id.start_with?(prefix) }&.last
387
+ end
388
+
389
+ def fetch_model_detail(model_name)
390
+ ctx = infer_context_window(model_name)
391
+ ctx ? { context_window: ctx } : nil
392
+ end
371
393
  end
372
394
  end
373
395
  end
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Llm
6
6
  module Anthropic
7
- VERSION = '0.2.7'
7
+ VERSION = '0.2.8'
8
8
  end
9
9
  end
10
10
  end
@@ -11,7 +11,7 @@ module Legion
11
11
  module Extensions
12
12
  module Llm
13
13
  # Anthropic provider extension namespace.
14
- module Anthropic
14
+ module Anthropic # rubocop:disable Metrics/ModuleLength
15
15
  extend ::Legion::Extensions::Core if ::Legion::Extensions.const_defined?(:Core, false)
16
16
  extend Legion::Logging::Helper
17
17
  extend Legion::Extensions::Llm::AutoRegistration
@@ -22,6 +22,7 @@ module Legion
22
22
  ::Legion::Extensions::Llm.provider_settings(
23
23
  family: PROVIDER_FAMILY,
24
24
  instance: {
25
+ default_model: 'claude-sonnet-4-6',
25
26
  endpoint: 'https://api.anthropic.com',
26
27
  tier: :frontier,
27
28
  transport: :http,
@@ -45,7 +46,7 @@ module Legion
45
46
  end
46
47
 
47
48
  def self.provider_aliases
48
- [:claude]
49
+ []
49
50
  end
50
51
 
51
52
  def self.discover_instances # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@@ -56,7 +57,9 @@ module Legion
56
57
  candidates[:env] = {
57
58
  api_key: env_key,
58
59
  anthropic_api_key: env_key,
59
- tier: :frontier
60
+ tier: :frontier,
61
+ source: CredentialSources.source_tag(:env, 'ANTHROPIC_API_KEY'),
62
+ credential_fingerprint: CredentialSources.credential_fingerprint(env_key)
60
63
  }
61
64
  end
62
65
 
@@ -65,7 +68,9 @@ module Legion
65
68
  candidates[:claude] = {
66
69
  api_key: claude_key,
67
70
  anthropic_api_key: claude_key,
68
- tier: :frontier
71
+ tier: :frontier,
72
+ source: CredentialSources.source_tag(:file, '~/.claude/settings.json', 'anthropicApiKey'),
73
+ credential_fingerprint: CredentialSources.credential_fingerprint(claude_key)
69
74
  }
70
75
  end
71
76
 
@@ -76,7 +81,9 @@ module Legion
76
81
  candidates[:settings] = normalize_instance_config(settings_config).merge(
77
82
  api_key: settings_key,
78
83
  anthropic_api_key: settings_key,
79
- tier: :frontier
84
+ tier: :frontier,
85
+ source: CredentialSources.source_tag(:settings, 'extensions.llm.anthropic'),
86
+ credential_fingerprint: CredentialSources.credential_fingerprint(settings_key)
80
87
  )
81
88
  end
82
89
 
@@ -87,6 +94,10 @@ module Legion
87
94
  next unless normalized[:anthropic_api_key]
88
95
 
89
96
  normalized[:api_key] = normalized[:anthropic_api_key]
97
+ normalized[:source] =
98
+ CredentialSources.source_tag(:settings, "extensions.llm.anthropic.instances.#{name}")
99
+ normalized[:credential_fingerprint] =
100
+ CredentialSources.credential_fingerprint(normalized[:anthropic_api_key])
90
101
  candidates[name.to_sym] = normalized.merge(tier: :frontier)
91
102
  end
92
103
  end
@@ -97,12 +108,19 @@ module Legion
97
108
  candidates[:broker] = {
98
109
  api_key: broker_cred,
99
110
  anthropic_api_key: broker_cred,
100
- tier: :frontier
111
+ tier: :frontier,
112
+ source: CredentialSources.source_tag(:broker, 'identity', 'anthropic'),
113
+ credential_fingerprint: CredentialSources.credential_fingerprint(broker_cred)
101
114
  }
102
115
  end
103
116
  end
104
117
 
105
- CredentialSources.dedup_credentials(candidates).transform_values { |config| sanitize_instance_config(config) }
118
+ CredentialSources.dedup_credentials(candidates).transform_values do |config|
119
+ sanitized = sanitize_instance_config(config)
120
+ sanitized[:capabilities] ||= %i[completion streaming vision].freeze
121
+ sanitized[:default_model] ||= 'claude-sonnet-4-6'
122
+ sanitized
123
+ end
106
124
  end
107
125
 
108
126
  def self.settings_instances(config)
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.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - LegionIO