Class: Legion::Extensions::Llm::AzureFoundry::Actor::AzureFoundryCallable
- Inherits:
-
Object
- Object
- Legion::Extensions::Llm::AzureFoundry::Actor::AzureFoundryCallable
- Defined in:
- lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb
Overview
Callable wrapper for an Azure Foundry provider instance. Implements
the fleet dispatch operations by delegating to the per-instance
AzureFoundry::Provider (errors propagate so
normalize_dispatch_error can classify them), plus the disconnect
and normalize_dispatch_error(error:) contracts required by
Inventory::CallableHandle and Routing::ProviderOutcome.
The fleet passes model: as a raw string (the offering's model id).
chat/stream_chat render paths call model.id (the stock
OpenAICompatible#render_payload), so a Model::Info is required
there; embed/count_tokens are string-tolerant (Provider#model_id
accepts the value verbatim), so those pass through — wrapping them
would serialize a Data object into the wire payload/response.
Instance Method Summary collapse
- #chat(messages:, model:, **rest) ⇒ Object
- #count_tokens(messages:, model:, **rest) ⇒ Object
- #disconnect ⇒ Object
- #disconnected? ⇒ Boolean
- #embed(text:, model:, **rest) ⇒ Object
-
#initialize(instance_cfg:, logger:, provider: nil) ⇒ AzureFoundryCallable
constructor
A new instance of AzureFoundryCallable.
-
#normalize_dispatch_error(error:) ⇒ Object
D17: production dispatch raises Legion::Extensions::Llm::*Error (ErrorMiddleware), not raw Faraday — the base Provider#normalize_dispatch_error classifies those.
- #provider ⇒ Object
- #stream_chat(messages:, model:, **rest) ⇒ Object
Constructor Details
#initialize(instance_cfg:, logger:, provider: nil) ⇒ AzureFoundryCallable
Returns a new instance of AzureFoundryCallable.
1005 1006 1007 1008 1009 1010 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 1005 def initialize(instance_cfg:, logger:, provider: nil) @instance_cfg = instance_cfg @logger = logger @provider = provider @disconnected = false end |
Instance Method Details
#chat(messages:, model:, **rest) ⇒ Object
1026 1027 1028 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 1026 def chat(messages:, model:, **rest) provider.chat(messages: , model: to_model_info(model), **rest) end |
#count_tokens(messages:, model:, **rest) ⇒ Object
1038 1039 1040 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 1038 def count_tokens(messages:, model:, **rest) provider.count_tokens(messages: , model: model, **rest) end |
#disconnect ⇒ Object
1020 1021 1022 1023 1024 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 1020 def disconnect @disconnected = true @provider&.disconnect @logger.debug { '[azure_foundry][callable] disconnected' } end |
#disconnected? ⇒ Boolean
1016 1017 1018 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 1016 def disconnected? @disconnected end |
#embed(text:, model:, **rest) ⇒ Object
1034 1035 1036 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 1034 def (text:, model:, **rest) provider.(text: text, model: model, **rest) end |
#normalize_dispatch_error(error:) ⇒ Object
D17: production dispatch raises Legion::Extensions::Llm::*Error (ErrorMiddleware), not raw Faraday — the base Provider#normalize_dispatch_error classifies those. On top, Azure wire semantics supply two stronger signals: an explicit EndpointDeactivated body (the ONLY instance_unavailable signal) and a model-not-ready 503 body (request-local, not instance-down).
1048 1049 1050 1051 1052 1053 1054 1055 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 1048 def normalize_dispatch_error(error:) outcome = base_provider_outcome(error: error) return outcome_with_kind(outcome, :instance_unavailable) if explicit_endpoint_deactivated?(error: error) return outcome_with_kind(outcome, :model_not_ready) if model_not_ready_outcome?(outcome, error: error) return outcome_with_kind(outcome, :model_missing) if model_missing_outcome?(outcome, error: error) outcome end |
#provider ⇒ Object
1012 1013 1014 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 1012 def provider @provider ||= Legion::Extensions::Llm::AzureFoundry::Provider.new(@instance_cfg) end |
#stream_chat(messages:, model:, **rest) ⇒ Object
1030 1031 1032 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 1030 def stream_chat(messages:, model:, **rest, &) provider.stream(messages: , model: to_model_info(model), **rest, &) end |