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.
907 908 909 910 911 912 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 907 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
928 929 930 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 928 def chat(messages:, model:, **rest) provider.chat(messages: , model: to_model_info(model), **rest) end |
#count_tokens(messages:, model:, **rest) ⇒ Object
940 941 942 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 940 def count_tokens(messages:, model:, **rest) provider.count_tokens(messages: , model: model, **rest) end |
#disconnect ⇒ Object
922 923 924 925 926 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 922 def disconnect @disconnected = true @provider&.disconnect @logger.debug { '[azure_foundry][callable] disconnected' } end |
#disconnected? ⇒ Boolean
918 919 920 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 918 def disconnected? @disconnected end |
#embed(text:, model:, **rest) ⇒ Object
936 937 938 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 936 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).
950 951 952 953 954 955 956 957 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 950 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
914 915 916 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 914 def provider @provider ||= Legion::Extensions::Llm::AzureFoundry::Provider.new(@instance_cfg) end |
#stream_chat(messages:, model:, **rest) ⇒ Object
932 933 934 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 932 def stream_chat(messages:, model:, **rest, &) provider.stream(messages: , model: to_model_info(model), **rest, &) end |