Class: LexLLM::Routing::ModelOffering
- Inherits:
-
Object
- Object
- LexLLM::Routing::ModelOffering
- Defined in:
- lib/lex_llm/routing/model_offering.rb
Overview
Describes one concrete model made available by one provider instance.
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#cost ⇒ Object
readonly
Returns the value of attribute cost.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#health ⇒ Object
readonly
Returns the value of attribute health.
-
#instance_id ⇒ Object
readonly
Returns the value of attribute instance_id.
-
#limits ⇒ Object
readonly
Returns the value of attribute limits.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#policy_tags ⇒ Object
readonly
Returns the value of attribute policy_tags.
-
#provider_family ⇒ Object
readonly
Returns the value of attribute provider_family.
-
#tier ⇒ Object
readonly
Returns the value of attribute tier.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
-
#usage_type ⇒ Object
readonly
Returns the value of attribute usage_type.
Instance Method Summary collapse
- #context_window ⇒ Object
- #eligibility_fingerprint ⇒ Object
- #eligible_for?(usage_type: nil, required_capabilities: [], min_context_window: nil, policy_tags: []) ⇒ Boolean
- #embedding? ⇒ Boolean
- #enabled? ⇒ Boolean
- #inference? ⇒ Boolean
-
#initialize(data) ⇒ ModelOffering
constructor
A new instance of ModelOffering.
- #lane_key(prefix: 'llm.fleet', include_context: true, include_fingerprint: false) ⇒ Object
- #max_output_tokens ⇒ Object
- #supports?(capability) ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ ModelOffering
Returns a new instance of ModelOffering.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/lex_llm/routing/model_offering.rb', line 10 def initialize(data) @provider_family = normalize_symbol(fetch_value(data, :provider_family, fetch_value(data, :provider))) @instance_id = normalize_symbol(fetch_value(data, :instance_id, @provider_family)) @transport = normalize_symbol(fetch_value(data, :transport, :http)) @tier = normalize_symbol(fetch_value(data, :tier, default_tier)) @model = fetch_value(data, :model).to_s @usage_type = normalize_usage_type(fetch_value(data, :usage_type, fetch_value(data, :type) || fetch_value(data, :kind) || infer_usage_type(data))) @capabilities = normalize_array(fetch_value(data, :capabilities)) @limits = normalize_hash(fetch_value(data, :limits)) @credentials = fetch_value(data, :credentials) @health = normalize_hash(fetch_value(data, :health)) @cost = normalize_hash(fetch_value(data, :cost)) @policy_tags = normalize_array(fetch_value(data, :policy_tags)).map(&:to_sym) @metadata = normalize_hash(fetch_value(data, :metadata)) end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def capabilities @capabilities end |
#cost ⇒ Object (readonly)
Returns the value of attribute cost.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def cost @cost end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def credentials @credentials end |
#health ⇒ Object (readonly)
Returns the value of attribute health.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def health @health end |
#instance_id ⇒ Object (readonly)
Returns the value of attribute instance_id.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def instance_id @instance_id end |
#limits ⇒ Object (readonly)
Returns the value of attribute limits.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def limits @limits end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def @metadata end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def model @model end |
#policy_tags ⇒ Object (readonly)
Returns the value of attribute policy_tags.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def @policy_tags end |
#provider_family ⇒ Object (readonly)
Returns the value of attribute provider_family.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def provider_family @provider_family end |
#tier ⇒ Object (readonly)
Returns the value of attribute tier.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def tier @tier end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def transport @transport end |
#usage_type ⇒ Object (readonly)
Returns the value of attribute usage_type.
7 8 9 |
# File 'lib/lex_llm/routing/model_offering.rb', line 7 def usage_type @usage_type end |
Instance Method Details
#context_window ⇒ Object
41 42 43 |
# File 'lib/lex_llm/routing/model_offering.rb', line 41 def context_window integer_limit(:context_window) || integer_limit(:max_input_tokens) end |
#eligibility_fingerprint ⇒ Object
67 68 69 |
# File 'lib/lex_llm/routing/model_offering.rb', line 67 def eligibility_fingerprint LaneKey.eligibility_fingerprint(self) end |
#eligible_for?(usage_type: nil, required_capabilities: [], min_context_window: nil, policy_tags: []) ⇒ Boolean
53 54 55 56 57 58 59 60 61 |
# File 'lib/lex_llm/routing/model_offering.rb', line 53 def eligible_for?(usage_type: nil, required_capabilities: [], min_context_window: nil, policy_tags: []) return false unless enabled? return false unless usage_type_matches?(usage_type) return false unless capabilities_match?(required_capabilities) return false unless context_window_matches?(min_context_window) return false unless () true end |
#embedding? ⇒ Boolean
33 34 35 |
# File 'lib/lex_llm/routing/model_offering.rb', line 33 def usage_type == :embedding end |
#enabled? ⇒ Boolean
29 30 31 |
# File 'lib/lex_llm/routing/model_offering.rb', line 29 def enabled? !.key?(:enabled) || [:enabled] != false end |
#inference? ⇒ Boolean
37 38 39 |
# File 'lib/lex_llm/routing/model_offering.rb', line 37 def inference? %i[chat inference completion].include?(usage_type) end |
#lane_key(prefix: 'llm.fleet', include_context: true, include_fingerprint: false) ⇒ Object
63 64 65 |
# File 'lib/lex_llm/routing/model_offering.rb', line 63 def lane_key(prefix: 'llm.fleet', include_context: true, include_fingerprint: false) LaneKey.for(self, prefix:, include_context:, include_fingerprint:) end |
#max_output_tokens ⇒ Object
45 46 47 |
# File 'lib/lex_llm/routing/model_offering.rb', line 45 def max_output_tokens integer_limit(:max_output_tokens) end |
#supports?(capability) ⇒ Boolean
49 50 51 |
# File 'lib/lex_llm/routing/model_offering.rb', line 49 def supports?(capability) capabilities.include?(capability.to_sym) end |
#to_h ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/lex_llm/routing/model_offering.rb', line 71 def to_h { provider_family: provider_family, instance_id: instance_id, transport: transport, tier: tier, model: model, usage_type: usage_type, capabilities: capabilities, limits: limits, credentials: credentials, health: health, cost: cost, policy_tags: , metadata: } end |