Class: SolidLoop::Pipeline::Context
- Inherits:
-
Object
- Object
- SolidLoop::Pipeline::Context
- Defined in:
- lib/solid_loop/pipeline/context.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
Inputs.
-
#aggregator ⇒ Object
Returns the value of attribute aggregator.
-
#assistant_message ⇒ Object
Returns the value of attribute assistant_message.
-
#content_started_at ⇒ Object
Returns the value of attribute content_started_at.
-
#debug_output ⇒ Object
Returns the value of attribute debug_output.
-
#detected_reasoning_field ⇒ Object
Returns the value of attribute detected_reasoning_field.
-
#duration ⇒ Object
Results.
-
#error_body ⇒ Object
Captured (non-2xx) failing-response envelope so the wire-log Event can persist status/headers/body even when the streaming adapter has already drained response.body via on_data.
-
#error_headers ⇒ Object
Captured (non-2xx) failing-response envelope so the wire-log Event can persist status/headers/body even when the streaming adapter has already drained response.body via on_data.
-
#error_status ⇒ Object
Captured (non-2xx) failing-response envelope so the wire-log Event can persist status/headers/body even when the streaming adapter has already drained response.body via on_data.
-
#event ⇒ Object
Returns the value of attribute event.
-
#exception ⇒ Object
Returns the value of attribute exception.
-
#execution_token ⇒ Object
Returns the value of attribute execution_token.
-
#first_token_at ⇒ Object
Returns the value of attribute first_token_at.
-
#heartbeat ⇒ Object
The background lease renewer for THIS turn.
-
#last_ui_update_at ⇒ Object
Returns the value of attribute last_ui_update_at.
-
#log_buffer ⇒ Object
Returns the value of attribute log_buffer.
-
#loop ⇒ Object
Inputs.
-
#messages ⇒ Object
ActiveRecord relation.
-
#messages_text_for_token_estimation ⇒ Object
Working state.
-
#metadata ⇒ Object
Hash for middlewares to share custom state.
-
#model_config ⇒ Object
Inputs.
-
#normalized_data ⇒ Object
Data normalized by the dialect.
-
#payload ⇒ Object
The hash that will be sent to the LLM (messages, tools, model, etc).
-
#request_started_at ⇒ Object
Returns the value of attribute request_started_at.
-
#request_url ⇒ Object
Returns the value of attribute request_url.
-
#response ⇒ Object
Faraday response object.
-
#timings ⇒ Object
Returns the value of attribute timings.
-
#triggering_message ⇒ Object
Returns the value of attribute triggering_message.
Instance Method Summary collapse
-
#initialize(loop_id:, execution_token: nil) ⇒ Context
constructor
A new instance of Context.
- #loop_active? ⇒ Boolean
- #loop_active_fresh? ⇒ Boolean
-
#mark_request_started! ⇒ Object
Used by inner layers to record timing precisely.
Constructor Details
#initialize(loop_id:, execution_token: nil) ⇒ Context
Returns a new instance of Context.
38 39 40 41 42 43 |
# File 'lib/solid_loop/pipeline/context.rb', line 38 def initialize(loop_id:, execution_token: nil) @loop = SolidLoop::Loop.find(loop_id) @execution_token = execution_token @metadata = {} @payload = {} end |
Instance Attribute Details
#agent ⇒ Object
Inputs
5 6 7 |
# File 'lib/solid_loop/pipeline/context.rb', line 5 def agent @agent end |
#aggregator ⇒ Object
Returns the value of attribute aggregator.
15 16 17 |
# File 'lib/solid_loop/pipeline/context.rb', line 15 def aggregator @aggregator end |
#assistant_message ⇒ Object
Returns the value of attribute assistant_message.
13 14 15 |
# File 'lib/solid_loop/pipeline/context.rb', line 13 def @assistant_message end |
#content_started_at ⇒ Object
Returns the value of attribute content_started_at.
14 15 16 |
# File 'lib/solid_loop/pipeline/context.rb', line 14 def content_started_at @content_started_at end |
#debug_output ⇒ Object
Returns the value of attribute debug_output.
16 17 18 |
# File 'lib/solid_loop/pipeline/context.rb', line 16 def debug_output @debug_output end |
#detected_reasoning_field ⇒ Object
Returns the value of attribute detected_reasoning_field.
29 30 31 |
# File 'lib/solid_loop/pipeline/context.rb', line 29 def detected_reasoning_field @detected_reasoning_field end |
#duration ⇒ Object
Results
20 21 22 |
# File 'lib/solid_loop/pipeline/context.rb', line 20 def duration @duration end |
#error_body ⇒ Object
Captured (non-2xx) failing-response envelope so the wire-log Event can persist status/headers/body even when the streaming adapter has already drained response.body via on_data.
26 27 28 |
# File 'lib/solid_loop/pipeline/context.rb', line 26 def error_body @error_body end |
#error_headers ⇒ Object
Captured (non-2xx) failing-response envelope so the wire-log Event can persist status/headers/body even when the streaming adapter has already drained response.body via on_data.
26 27 28 |
# File 'lib/solid_loop/pipeline/context.rb', line 26 def error_headers @error_headers end |
#error_status ⇒ Object
Captured (non-2xx) failing-response envelope so the wire-log Event can persist status/headers/body even when the streaming adapter has already drained response.body via on_data.
26 27 28 |
# File 'lib/solid_loop/pipeline/context.rb', line 26 def error_status @error_status end |
#event ⇒ Object
Returns the value of attribute event.
12 13 14 |
# File 'lib/solid_loop/pipeline/context.rb', line 12 def event @event end |
#exception ⇒ Object
Returns the value of attribute exception.
28 29 30 |
# File 'lib/solid_loop/pipeline/context.rb', line 28 def exception @exception end |
#execution_token ⇒ Object
Returns the value of attribute execution_token.
31 32 33 |
# File 'lib/solid_loop/pipeline/context.rb', line 31 def execution_token @execution_token end |
#first_token_at ⇒ Object
Returns the value of attribute first_token_at.
14 15 16 |
# File 'lib/solid_loop/pipeline/context.rb', line 14 def first_token_at @first_token_at end |
#heartbeat ⇒ Object
The background lease renewer for THIS turn. ResponseParsing
(and any other canonical-write site) calls heartbeat&.check! before
committing, so a worker whose lease was lost mid-stream raises
SolidLoop::LostLease instead of writing a turn it no longer owns.
36 37 38 |
# File 'lib/solid_loop/pipeline/context.rb', line 36 def heartbeat @heartbeat end |
#last_ui_update_at ⇒ Object
Returns the value of attribute last_ui_update_at.
14 15 16 |
# File 'lib/solid_loop/pipeline/context.rb', line 14 def last_ui_update_at @last_ui_update_at end |
#log_buffer ⇒ Object
Returns the value of attribute log_buffer.
16 17 18 |
# File 'lib/solid_loop/pipeline/context.rb', line 16 def log_buffer @log_buffer end |
#loop ⇒ Object
Inputs
5 6 7 |
# File 'lib/solid_loop/pipeline/context.rb', line 5 def loop @loop end |
#messages ⇒ Object
ActiveRecord relation
6 7 8 |
# File 'lib/solid_loop/pipeline/context.rb', line 6 def @messages end |
#messages_text_for_token_estimation ⇒ Object
Working state
11 12 13 |
# File 'lib/solid_loop/pipeline/context.rb', line 11 def @messages_text_for_token_estimation end |
#metadata ⇒ Object
Hash for middlewares to share custom state
30 31 32 |
# File 'lib/solid_loop/pipeline/context.rb', line 30 def @metadata end |
#model_config ⇒ Object
Inputs
5 6 7 |
# File 'lib/solid_loop/pipeline/context.rb', line 5 def model_config @model_config end |
#normalized_data ⇒ Object
Data normalized by the dialect
27 28 29 |
# File 'lib/solid_loop/pipeline/context.rb', line 27 def normalized_data @normalized_data end |
#payload ⇒ Object
The hash that will be sent to the LLM (messages, tools, model, etc)
7 8 9 |
# File 'lib/solid_loop/pipeline/context.rb', line 7 def payload @payload end |
#request_started_at ⇒ Object
Returns the value of attribute request_started_at.
14 15 16 |
# File 'lib/solid_loop/pipeline/context.rb', line 14 def request_started_at @request_started_at end |
#request_url ⇒ Object
Returns the value of attribute request_url.
21 22 23 |
# File 'lib/solid_loop/pipeline/context.rb', line 21 def request_url @request_url end |
#response ⇒ Object
Faraday response object
22 23 24 |
# File 'lib/solid_loop/pipeline/context.rb', line 22 def response @response end |
#timings ⇒ Object
Returns the value of attribute timings.
17 18 19 |
# File 'lib/solid_loop/pipeline/context.rb', line 17 def timings @timings end |
#triggering_message ⇒ Object
Returns the value of attribute triggering_message.
8 9 10 |
# File 'lib/solid_loop/pipeline/context.rb', line 8 def @triggering_message end |
Instance Method Details
#loop_active? ⇒ Boolean
45 46 47 48 |
# File 'lib/solid_loop/pipeline/context.rb', line 45 def loop_active? # Fail closed: a context without a generation token never owns the loop. @loop.running? && @execution_token.present? && @loop.execution_token == @execution_token end |
#loop_active_fresh? ⇒ Boolean
50 51 52 53 |
# File 'lib/solid_loop/pipeline/context.rb', line 50 def loop_active_fresh? @loop.reload loop_active? end |
#mark_request_started! ⇒ Object
Used by inner layers to record timing precisely
56 57 58 |
# File 'lib/solid_loop/pipeline/context.rb', line 56 def mark_request_started! @request_started_at = Time.current end |