Module: Legion::Extensions::Llm::AzureFoundry::ProviderDispatchMethods

Included in:
Provider
Defined in:
lib/legion/extensions/llm/azure_foundry/provider.rb

Overview

Public dispatch methods — chat, stream, embed. count_tokens inherits the base heuristic (Integer estimate, 05 §2) — the operation's support is carried by the SSOT data plane (writer operation evidence + WorkerExecution.require_supported!), not by a per-call artifact.

Canonical boundary (N x N law): the shared lex-llm enforce_canonical_messages! helper runs at every message-operation entry (08 F2, 12/O05 — one shared helper, called at every operation entry). Pipeline dispatch (direct SelectionDispatch, fleet worker rehydration) delivers Canonical::Message objects and nothing else; plain Hashes are the bypass class (the 2026-08-19 incident) — rejected loudly, never silently coerced. The model travels as the Selection-derived String, untouched (08 F3, B4); sampling params travel as Canonical::Params (05 O4).

Instance Method Summary collapse

Instance Method Details

#chat(messages, model:, **options) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 72

def chat(messages, model:, **options)
  enforce_canonical_messages!(messages)
  log.info { "chat request model=#{model} messages=#{messages.size}" }
  complete(messages, tools: options.fetch(:tools, {}),
                     model: model,
                     params: canonical_params(options), tool_prefs: options[:tool_prefs])
end

#embed(text:, model:, **options) ⇒ Object



88
89
90
91
92
93
94
95
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 88

def embed(text:, model:, **options)
  enforce_model_allowed!(model)
  log.info { "embed request model=#{model}" }
  payload = render_embedding_payload(text, model: model_id(model), dimensions: options[:dimensions])
  payload[:input_type] = options[:input_type] if options[:input_type]
  response = connection.post(embedding_url(model:), payload)
  parse_embedding_response(response, model: model_id(model), text:)
end

#stream(messages, model:, **options) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 80

def stream(messages, model:, **options, &)
  enforce_canonical_messages!(messages)
  log.info { "stream request model=#{model} messages=#{messages.size}" }
  complete(messages, tools: options.fetch(:tools, {}),
                     model: model,
                     params: canonical_params(options), tool_prefs: options[:tool_prefs], &)
end