Class: Brute::Turn::Pipeline

Inherits:
Rack::Builder
  • Object
show all
Includes:
Chainable
Defined in:
lib/brute/turn/pipeline.rb

Direct Known Subclasses

AgentPipeline

Defined Under Namespace

Modules: Chainable

Constant Summary

Constants included from Hooks

Hooks::COMPACT_DURATION_EVENT, Hooks::COMPACT_END_EVENT, Hooks::COMPACT_FAILURE_EVENT, Hooks::COMPACT_START_EVENT, Hooks::CONTENT_EVENT, Hooks::FARADAY_ERROR_EVENT, Hooks::LLM_DURATION_EVENT, Hooks::LLM_END_EVENT, Hooks::LLM_FAILURE_EVENT, Hooks::LLM_START_EVENT, Hooks::MIDDLEWARE_ADDED_EVENT, Hooks::MIDDLEWARE_DURATION_EVENT, Hooks::MIDDLEWARE_END_EVENT, Hooks::MIDDLEWARE_FAILURE_EVENT, Hooks::MIDDLEWARE_START_EVENT, Hooks::OPEN_ROUTER_SERVER_ERROR_EVENT, Hooks::REASONING_EVENT, Hooks::STANDARD_ERROR_EVENT, Hooks::TOOL_APPROVE_EVENT, Hooks::TOOL_CALLS_EVENT, Hooks::TOOL_DURATION_EVENT, Hooks::TOOL_END_EVENT, Hooks::TOOL_FAILURE_EVENT, Hooks::TOOL_START_EVENT, Hooks::TURN_DURATION_EVENT, Hooks::TURN_END_EVENT, Hooks::TURN_FAILURE_EVENT, Hooks::TURN_START_EVENT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Chainable

#on, #run, #use

Constructor Details

#initialize(default_app = nil, hooks: Brute::Hooks::Registry.new, **options, &block) ⇒ Pipeline

Returns a new instance of Pipeline.



109
110
111
112
# File 'lib/brute/turn/pipeline.rb', line 109

def initialize(default_app = nil, hooks: Brute::Hooks::Registry.new, **options, &block)
  @hooks = hooks
  super(default_app, **options, &block)
end

Instance Attribute Details

#hooksObject (readonly)

Returns the value of attribute hooks.



114
115
116
# File 'lib/brute/turn/pipeline.rb', line 114

def hooks
  @hooks
end

Class Method Details

.new_from_string(builder_script, path = "(rackup)", **options) ⇒ Object



100
101
102
103
104
# File 'lib/brute/turn/pipeline.rb', line 100

def self.new_from_string(builder_script, path = "(rackup)", **options)
  new(**options).tap do |builder|
    eval(builder_script, ::Rack::BUILDER_TOPLEVEL_BINDING.call(builder), path) # rubocop:disable Security/Eval
  end
end

Instance Method Details

#call(env) ⇒ Object

Every way into a pipeline arrives at a Trace: what a caller hands over is wrapped once, and a pipeline entered from inside another keeps the trace it was already in.



119
120
121
# File 'lib/brute/turn/pipeline.rb', line 119

def call(env)
  env.is_a?(Brute::Hooks::Trace) ? super : super(Brute::Hooks::Trace.new(env, hooks: hooks))
end