Class: Legion::Extensions::Llm::Vllm::Helpers::OfferingBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/llm/vllm/helpers/offering_builder.rb

Overview

Standalone offering builder for vLLM discovery. Constructs OfferingDraft and all nested evidence structs from model catalog data and instance configuration. No state, no side effects.

Instance Method Summary collapse

Constructor Details

#initialize(instance_cfg:, instance_key:) ⇒ OfferingBuilder

Returns a new instance of OfferingBuilder.



15
16
17
18
# File 'lib/legion/extensions/llm/vllm/helpers/offering_builder.rb', line 15

def initialize(instance_cfg:, instance_key:)
  @instance_cfg = instance_cfg
  @instance_key = instance_key
end

Instance Method Details

#build(model_id:, model_data:) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/legion/extensions/llm/vllm/helpers/offering_builder.rb', line 20

def build(model_id:, model_data:)
  tier = @instance_cfg[:tier] || :direct
  embed_sup = embedding_supported?(model_data)
  max_output = model_data[:max_output_tokens] || model_data[:max_completion_tokens]
  weight_inputs = Legion::Extensions::Llm::Inventory::WeightSchema.weight_inputs(
    settings: Legion::Settings,
    instance_key: instance_key,
    provider_native_key: model_id,
    model: model_id,
    tier: tier
  )

  Legion::Extensions::Llm::Inventory::OfferingDraft.new(
    provider_native_key: model_id,
    model: model_id,
    tier: tier,
    operation_evidence: build_operation_evidence(embed_supported: embed_sup),
    capability_evidence: build_capability_evidence(model_id: model_id, embed_supported: embed_sup),
    context_evidence: build_value_evidence(model_data[:max_model_len]),
    max_output_evidence: build_value_evidence(max_output),
    embedding_dimensions_evidence: build_embedding_dims_evidence(model_data, embed_sup),
    model_revision_evidence: build_string_evidence(model_data[:revision] || model_data[:model_revision]),
    tokenizer_evidence: build_tokenizer_evidence(model_data[:tokenizer]),
    quota_domains: {},
    metadata: (model_data),
    publication_source: :provider_catalog,
    weight_inputs: weight_inputs,
    base_weight: Legion::Extensions::Llm::Inventory::WeightSchema.base_weight(weight_inputs)
  )
end