Module: Legion::LLM::Pipeline::Steps::PostResponse

Includes:
Legion::Logging::Helper
Included in:
Executor
Defined in:
lib/legion/llm/pipeline/steps/post_response.rb

Instance Method Summary collapse

Instance Method Details

#step_post_responseObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/legion/llm/pipeline/steps/post_response.rb', line 12

def step_post_response
  response = current_response

  audit_event = AuditPublisher.publish(request: @request, response: response)

  Legion::Gaia::AuditObserver.instance.process_event(audit_event) if defined?(Legion::Gaia::AuditObserver) && audit_event

  @timeline.record(
    category: :audit, key: 'audit:publish',
    direction: :outbound, detail: 'published to llm.audit',
    from: 'pipeline', to: 'llm.audit'
  )
rescue StandardError => e
  @warnings << "post_response error: #{e.message}"
  handle_exception(e, level: :warn, operation: 'llm.pipeline.steps.post_response')
end