Class: Legion::Extensions::Llm::Transport::Messages::FleetResponse

Inherits:
Transport::Message
  • Object
show all
Includes:
Fleet::DefaultExchangeReply, Fleet::EnvelopeValidation
Defined in:
lib/legion/extensions/llm/transport/messages/fleet_response.rb

Overview

Correlated protocol-v2 response envelope for fleet reply queues.

Constant Summary

Constants included from Fleet::EnvelopeValidation

Fleet::EnvelopeValidation::LEGACY_OPTIONS

Constants included from Fleet::DefaultExchangeReply

Fleet::DefaultExchangeReply::DEFAULT_REPLY_PUBLISH_OPTIONS

Instance Method Summary collapse

Methods included from Fleet::DefaultExchangeReply

#publish

Instance Method Details

#app_idObject



20
# File 'lib/legion/extensions/llm/transport/messages/fleet_response.rb', line 20

def app_id = @options[:app_id] || 'lex-llm'

#correlation_idObject



22
# File 'lib/legion/extensions/llm/transport/messages/fleet_response.rb', line 22

def correlation_id = @options[:correlation_id]

#messageObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/legion/extensions/llm/transport/messages/fleet_response.rb', line 38

def message
  super.except(:thinking).merge(
    protocol_version: @options[:protocol_version] || Fleet::Protocol::VERSION,
    request_id: @options[:request_id],
    correlation_id: correlation_id,
    idempotency_key: @options[:idempotency_key],
    operation: @options[:operation],
    provider: @options[:provider],
    provider_instance: @options[:provider_instance] || @options[:instance],
    model: @options[:model],
    reply_to: reply_to,
    message_context: @options[:message_context],
    trace_context: @options[:trace_context],
    content: @options[:content],
    tool_calls: @options[:tool_calls],
    usage: @options[:usage] || {},
    finish_reason: @options[:finish_reason],
    metadata: @options[:metadata] || {}
  ).compact
end

#message_idObject



23
# File 'lib/legion/extensions/llm/transport/messages/fleet_response.rb', line 23

def message_id = @options[:message_id] ||= "llm_fleet_res_#{SecureRandom.uuid}"

#reply_toObject



21
# File 'lib/legion/extensions/llm/transport/messages/fleet_response.rb', line 21

def reply_to = @options[:reply_to]

#routing_keyObject



25
26
27
# File 'lib/legion/extensions/llm/transport/messages/fleet_response.rb', line 25

def routing_key
  @options[:reply_to] || raise(ArgumentError, 'reply_to is required')
end

#typeObject



19
# File 'lib/legion/extensions/llm/transport/messages/fleet_response.rb', line 19

def type = Fleet::Protocol::RESPONSE_TYPE

#validateObject



29
30
31
32
33
34
35
36
# File 'lib/legion/extensions/llm/transport/messages/fleet_response.rb', line 29

def validate
  reject_legacy_options!
  require_option!(:request_id)
  require_option!(:correlation_id)
  require_option!(:reply_to)
  require_protocol_version!
  @valid = true
end