lex-llm-vertex 0.2.8 → 0.2.9

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: d7dbca12cb0f99264ee9fd713291622b0ee9ad6f238193811bdcfb2847be3211
4
- data.tar.gz: be61eafce74bdaec30c737ec906abafbbacad3f4c125b52199db8de8dd3d3ca6
3
+ metadata.gz: acd43f914dff394b9635eb7596dd108016764e573fe35a477f267c3ab8465971
4
+ data.tar.gz: 2ee16d4671f38bd7c5ce4de50ea6abd3b1ad4609c06fcf559d89e224c36baa77
5
5
  SHA512:
6
- metadata.gz: f557d2fbf831656f3aa0d4a0788ecfedab7889f5d9fdd666300ddad2be3348184e56c8bc0f5d3a469b64d9d12e2fae846bcfbd97100ff6a8b1f755cdaea803c2
7
- data.tar.gz: 90199aa13e8d105931040d6131f9c1591cc7bc956dd61e0046589a7eba06d0ab5aae04cd8fdce276a28adafd980e8c3a4a781687bc626e31097a719a8c47220b
6
+ metadata.gz: 47e8e573e518356cc1de63b8f0120bd96024d22266a7a0e37ff9d3e8ed5528028f0a30253d7a48a59d881a5043be6b7100becd6d45ffe13815b5fad715d9647a
7
+ data.tar.gz: '09d51a90aa46a6595aa611e998f2de12e67d761563c17bab6919fa77ec25c3e7eabf139ae2644915ce0a435e887b217d9c509dcec6f74faf4b75e484300f76e7'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.9 - 2026-05-21
4
+
5
+ - Add `default_transport`/`default_tier` class declarations, remove `configured_transport`/`configured_tier`
6
+ - Remove `DEFAULT_LOCATION`/`DEFAULT_PROJECT`/`DEFAULT_PUBLISHER` constants — now read from settings
7
+ - Add `model_allowed?` filtering in `discover_offerings`
8
+ - Default tier corrected from :frontier to :cloud
9
+ - Identity headers included via base provider
10
+
11
+
3
12
  ## 0.2.8 - 2026-05-18
4
13
 
5
14
  - Fix streaming tool calls: `build_chunk` now passes `tool_calls: parse_tool_calls(parts)` to the Chunk constructor. Previously tool calls were omitted from streaming responses entirely.
@@ -11,10 +11,6 @@ module Legion
11
11
  module Vertex
12
12
  # Google Cloud Vertex AI provider implementation for the Legion::Extensions::Llm contract.
13
13
  class Provider < Legion::Extensions::Llm::Provider # rubocop:disable Metrics/ClassLength
14
- DEFAULT_LOCATION = 'us-central1'
15
- DEFAULT_PROJECT = 'env://GOOGLE_CLOUD_PROJECT'
16
- DEFAULT_PUBLISHER = 'google'
17
-
18
14
  STATIC_MODELS = [
19
15
  { model: 'gemini-2.5-flash', alias: 'gemini-flash', publisher: 'google', model_family: :gemini },
20
16
  { model: 'gemini-2.5-pro', alias: 'gemini-pro', publisher: 'google', model_family: :gemini },
@@ -39,6 +35,8 @@ module Legion
39
35
  attr_writer :registry_publisher
40
36
 
41
37
  def slug = 'vertex'
38
+ def default_transport = :http
39
+ def default_tier = :cloud
42
40
 
43
41
  def configuration_options
44
42
  %i[
@@ -83,16 +81,22 @@ module Legion
83
81
  end
84
82
  end
85
83
 
84
+ def settings
85
+ Vertex.default_settings
86
+ end
87
+
86
88
  def api_base
87
89
  config.vertex_api_base || "https://#{location}-aiplatform.googleapis.com/v1"
88
90
  end
89
91
 
90
92
  def headers
91
- { 'Authorization' => bearer_token, 'Content-Type' => 'application/json; charset=utf-8' }.compact
93
+ identity_headers.merge({ 'Authorization' => bearer_token,
94
+ 'Content-Type' => 'application/json; charset=utf-8' }.compact)
92
95
  end
93
96
 
94
- def project = config.vertex_project || ENV.fetch('GOOGLE_CLOUD_PROJECT', DEFAULT_PROJECT)
95
- def location = config.vertex_location || DEFAULT_LOCATION
97
+ def project = config.vertex_project || settings[:project] || ENV.fetch('GOOGLE_CLOUD_PROJECT', nil)
98
+ def location = config.vertex_location || settings[:location] || 'us-central1'
99
+ def default_publisher = settings[:publisher] || 'google'
96
100
  def models_url = publisher_parent
97
101
  def completion_url = generate_content_url(model: @model || STATIC_MODELS.first.fetch(:model))
98
102
  def stream_url = stream_generate_content_url(model: @model || STATIC_MODELS.first.fetch(:model))
@@ -126,7 +130,13 @@ module Legion
126
130
 
127
131
  response = connection.get(models_url)
128
132
  models = response.body['publisherModels'] || response.body['models'] || []
129
- offerings = models.map { |model| offering_from_live_model(model) }
133
+ offerings = models.filter_map do |model|
134
+ offering = offering_from_live_model(model)
135
+ model_id = offering.respond_to?(:model) ? offering.model : (offering[:model] || offering[:id])
136
+ next unless model_allowed?(model_id.to_s)
137
+
138
+ offering
139
+ end
130
140
  log.info { "discovered #{offerings.size} live offering(s) from Vertex" }
131
141
  model_infos = offerings.map { |o| model_info_from_offering(o) }
132
142
  self.class.registry_publisher.publish_models_async(model_infos, readiness: readiness(live: false))
@@ -310,7 +320,7 @@ module Legion
310
320
 
311
321
  def offering_from_live_model(model)
312
322
  name = model['name'] || model['publisherModelName'] || model['model'] || model['id']
313
- publisher = publisher_from_resource(name) || model['publisher'] || DEFAULT_PUBLISHER
323
+ publisher = publisher_from_resource(name) || model['publisher'] || default_publisher
314
324
  id = name.to_s.split('/').last
315
325
  offering_for(model: id, publisher:, metadata: model)
316
326
  end
@@ -320,8 +330,8 @@ module Legion
320
330
  Legion::Extensions::Llm::Routing::ModelOffering.new(
321
331
  provider_family: :vertex,
322
332
  instance_id: instance_id,
323
- transport: configured_transport(:http),
324
- tier: configured_tier(:frontier),
333
+ transport: offering_transport,
334
+ tier: offering_tier,
325
335
  model: model,
326
336
  usage_type: usage_type,
327
337
  capabilities: default_capabilities(model, api:),
@@ -337,16 +347,8 @@ module Legion
337
347
  )
338
348
  end
339
349
 
340
- def configured_transport(default)
341
- config.respond_to?(:transport) ? config.transport : default
342
- end
343
-
344
- def configured_tier(default)
345
- config.respond_to?(:tier) ? config.tier : default
346
- end
347
-
348
350
  def publisher_parent
349
- "projects/#{project}/locations/#{location}/publishers/#{DEFAULT_PUBLISHER}/models"
351
+ "projects/#{project}/locations/#{location}/publishers/#{default_publisher}/models"
350
352
  end
351
353
 
352
354
  def publisher_model_path(model)
@@ -651,7 +653,7 @@ module Legion
651
653
  id = model_id(model)
652
654
  return publisher_from_resource(id) if id.start_with?('projects/')
653
655
 
654
- PUBLISHERS.fetch(id, DEFAULT_PUBLISHER)
656
+ PUBLISHERS.fetch(id, default_publisher)
655
657
  end
656
658
 
657
659
  def publisher_from_resource(resource)
@@ -662,7 +664,7 @@ module Legion
662
664
  def api_for(model)
663
665
  id = model_id(model)
664
666
  return API_MODES[id] if API_MODES.key?(id)
665
- return :raw_predict if publisher_for(id) != DEFAULT_PUBLISHER && !Capabilities.embeddings?(id)
667
+ return :raw_predict if publisher_for(id) != default_publisher && !Capabilities.embeddings?(id)
666
668
 
667
669
  :generate_content
668
670
  end
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Llm
6
6
  module Vertex
7
- VERSION = '0.2.8'
7
+ VERSION = '0.2.9'
8
8
  end
9
9
  end
10
10
  end
@@ -20,7 +20,10 @@ module Legion
20
20
  family: PROVIDER_FAMILY,
21
21
  instance: {
22
22
  endpoint: nil,
23
- tier: :frontier,
23
+ project: nil,
24
+ location: 'us-central1',
25
+ publisher: 'google',
26
+ tier: :cloud,
24
27
  transport: :http,
25
28
  credentials: {
26
29
  access_token: nil,
@@ -28,7 +31,7 @@ module Legion
28
31
  },
29
32
  provider: {
30
33
  project: nil,
31
- location: Provider::DEFAULT_LOCATION,
34
+ location: 'us-central1',
32
35
  model_aliases: {}
33
36
  },
34
37
  usage: { inference: true, embedding: true, image: false },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-llm-vertex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - LegionIO