class Riffer::Rig::Runtime::Hooks
Public Class Methods
(Hash[Symbol, Array[^(Riffer::Rig::Events::_Event | ::Riffer::StreamEvents::Base) → untyped]] hooks, Riffer::Rig::Hosts::_Host host) → void
Source
# File lib/riffer/rig/runtime/hooks.rb, line 10 def initialize(hooks, host) @hooks = hooks @host = host end
@rbs hooks: Hash[Symbol, Array[^(Riffer::Rig::Events::_Event | ::Riffer::StreamEvents::Base) -> untyped]] @rbs host: Riffer::Rig::Hosts::_Host @rbs return: void
Public Instance Methods
(String text) → (String | Riffer::Rig::Runtime::Blocked)
Source
# File lib/riffer/rig/runtime/hooks.rb, line 24 def before_prompt(text) accepts = ->(value) { value.is_a?(String) } announce(veto(:before_prompt, text, accepts) { |current| Riffer::Rig::Events::BeforePrompt.new(current) }) end
@rbs text: String @rbs return: String | Riffer::Rig::Runtime::Blocked
(Array[::Riffer::Messages::Base] messages) → (Array[::Riffer::Messages::Base] | Riffer::Rig::Runtime::Blocked)
Source
# File lib/riffer/rig/runtime/hooks.rb, line 43 def before_request(messages) accepts = ->(value) { value.is_a?(Array) && value.all?(::Riffer::Messages::Base) } announce(veto(:before_request, messages, accepts) { |current| Riffer::Rig::Events::BeforeRequest.new(current) }) end
@rbs messages: Array @rbs return: Array | Riffer::Rig::Runtime::Blocked
(String call_id, String tool, Hash[Symbol, untyped] args, Float at) → (Hash[Symbol, untyped] | Riffer::Rig::Runtime::Blocked)
Source
# File lib/riffer/rig/runtime/hooks.rb, line 34 def before_tool_call(call_id, tool, args, at) accepts = ->(value) { value.is_a?(Hash) } veto(:before_tool_call, args, accepts) do |current| Riffer::Rig::Events::BeforeToolCall.new(call_id, tool, current, at) end end
@rbs call_id: String @rbs tool: String @rbs args: Hash[Symbol, untyped] @rbs at: Float @rbs return: Hash[Symbol, untyped] | Riffer::Rig::Runtime::Blocked
(Symbol name, Riffer::Rig::Events::_Event | ::Riffer::StreamEvents::Base event) → void
Source
# File lib/riffer/rig/runtime/hooks.rb, line 18 def observe(name, event) @hooks.fetch(name).each { |hook| call(name, hook, event) } end
@rbs name: Symbol @rbs event: Riffer::Rig::Events::_Event | ::Riffer::StreamEvents::Base @rbs return: void