lex-llm-vertex 0.2.8 → 0.2.10
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: 25083d8e7cc928d57127feab13406395a6600421913559042fecfe7e2a376267
|
|
4
|
+
data.tar.gz: '028cb717f3299a2683bdd0ed10cc59f91a75f3de5f773d730ec75e2374762170'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69f44a1e8ac1d5d0da6b9e4ca5b5d5f7f0fba37b49021e5a512db86884958a89abd20323c336b9292c1973fb47e303d37b715322aaf37da75ab1f3d5da33a48f
|
|
7
|
+
data.tar.gz: 53cb2cfeb3039b78ca84722943e220178b6a7c1a060972ca329aacd4acb742bac4e4a581d9df819fa1902f315ca73858d9401d29ec08318c7ce0290899b11fc7
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.10 - 2026-06-02
|
|
4
|
+
|
|
5
|
+
- Add per-provider scoped discovery refresh actor
|
|
6
|
+
|
|
7
|
+
## 0.2.9 - 2026-05-21
|
|
8
|
+
|
|
9
|
+
- Add `default_transport`/`default_tier` class declarations, remove `configured_transport`/`configured_tier`
|
|
10
|
+
- Remove `DEFAULT_LOCATION`/`DEFAULT_PROJECT`/`DEFAULT_PUBLISHER` constants — now read from settings
|
|
11
|
+
- Add `model_allowed?` filtering in `discover_offerings`
|
|
12
|
+
- Default tier corrected from :frontier to :cloud
|
|
13
|
+
- Identity headers included via base provider
|
|
14
|
+
|
|
15
|
+
|
|
3
16
|
## 0.2.8 - 2026-05-18
|
|
4
17
|
|
|
5
18
|
- 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.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
begin
|
|
4
|
+
require 'legion/extensions/actors/every'
|
|
5
|
+
rescue LoadError => e
|
|
6
|
+
warn(e.message) if $VERBOSE
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
return unless defined?(Legion::Extensions::Actors::Every)
|
|
10
|
+
|
|
11
|
+
module Legion
|
|
12
|
+
module Extensions
|
|
13
|
+
module Llm
|
|
14
|
+
module Vertex
|
|
15
|
+
module Actor
|
|
16
|
+
class DiscoveryRefresh < Legion::Extensions::Actors::Every # rubocop:disable Style/Documentation
|
|
17
|
+
include Legion::Logging::Helper
|
|
18
|
+
|
|
19
|
+
REFRESH_INTERVAL = 1800
|
|
20
|
+
|
|
21
|
+
def runner_class = self.class
|
|
22
|
+
def runner_function = 'manual'
|
|
23
|
+
def run_now? = true
|
|
24
|
+
def use_runner? = false
|
|
25
|
+
def check_subtask? = false
|
|
26
|
+
def generate_task? = false
|
|
27
|
+
|
|
28
|
+
def time
|
|
29
|
+
return REFRESH_INTERVAL unless defined?(Legion::Settings)
|
|
30
|
+
|
|
31
|
+
Legion::Settings.dig(:extensions, :llm, :vertex, :discovery_interval) || REFRESH_INTERVAL
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def manual
|
|
35
|
+
log.debug('[vertex][discovery_refresh] refreshing model list')
|
|
36
|
+
return unless defined?(Legion::LLM::Discovery)
|
|
37
|
+
|
|
38
|
+
Legion::LLM::Discovery.refresh_discovered_models!(provider: :vertex)
|
|
39
|
+
rescue StandardError => e
|
|
40
|
+
handle_exception(e, level: :warn, handled: true, operation: 'vertex.actor.discovery_refresh')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -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,
|
|
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',
|
|
95
|
-
def location = config.vertex_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.
|
|
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'] ||
|
|
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:
|
|
324
|
-
tier:
|
|
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/#{
|
|
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,
|
|
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) !=
|
|
667
|
+
return :raw_predict if publisher_for(id) != default_publisher && !Capabilities.embeddings?(id)
|
|
666
668
|
|
|
667
669
|
:generate_content
|
|
668
670
|
end
|
|
@@ -20,7 +20,10 @@ module Legion
|
|
|
20
20
|
family: PROVIDER_FAMILY,
|
|
21
21
|
instance: {
|
|
22
22
|
endpoint: nil,
|
|
23
|
-
|
|
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:
|
|
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.
|
|
4
|
+
version: 0.2.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LegionIO
|
|
@@ -98,6 +98,7 @@ files:
|
|
|
98
98
|
- README.md
|
|
99
99
|
- lex-llm-vertex.gemspec
|
|
100
100
|
- lib/legion/extensions/llm/vertex.rb
|
|
101
|
+
- lib/legion/extensions/llm/vertex/actors/discovery_refresh.rb
|
|
101
102
|
- lib/legion/extensions/llm/vertex/actors/fleet_worker.rb
|
|
102
103
|
- lib/legion/extensions/llm/vertex/provider.rb
|
|
103
104
|
- lib/legion/extensions/llm/vertex/runners/fleet_worker.rb
|