Module: Phronomy::Agent::Concerns::BeforeCompletion::ClassMethods Private

Defined in:
lib/phronomy/agent/concerns/before_completion.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class-level DSL methods mixed into the including agent class.

Instance Method Summary collapse

Instance Method Details

#_before_completion#call?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (#call, nil)


41
42
43
# File 'lib/phronomy/agent/concerns/before_completion.rb', line 41

def _before_completion
  @before_completion
end

#before_completion(callable = nil) ⇒ #call?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sets or reads the class-level before_completion hook. The hook is called before every LLM request for instances of this class. Receives a BeforeCompletionContext; must return a Hash of params to merge into the LLM call, or nil to pass through unchanged.

Examples:

class MyAgent < Phronomy::Agent::Base
  before_completion ->(ctx) { { temperature: 0.2 } }
end

Parameters:

  • callable (#call, nil) (defaults to: nil)

    lambda/proc to register, or nil to clear

Returns:

  • (#call, nil)


31
32
33
34
35
36
37
# File 'lib/phronomy/agent/concerns/before_completion.rb', line 31

def before_completion(callable = nil)
  if callable.nil? && !block_given?
    @before_completion
  else
    @before_completion = callable
  end
end