Module: LLM::ActiveRecord::ActsAsAgent::ClassMethods

Defined in:
lib/llm/active_record/acts_as_agent.rb

Instance Method Summary collapse

Instance Method Details

#agent ⇒ Class<LLM::Agent>

Returns:



27
28
29
30
31
32
# File 'lib/llm/active_record/acts_as_agent.rb', line 27

def agent
  return @agent if defined?(@agent)
  @agent = Class.new(LLM::Agent)
  @agent.name(self)
  @agent
end

#set(properties)

This method returns an undefined value.

Bulk-assign class-level agent defaults.

Each key is resolved by calling the corresponding class method on the internal agent subclass.

Examples:

class Agent < ApplicationRecord
  acts_as_agent
  set instructions: "You are a system administrator",
      model: "gpt-4.1-nano",
      tools: [LLM::Tool::Exec]
end

Parameters:

  • properties (Hash)

Options Hash (properties):

  • :instructions (String)
  • :model (String)
  • :tools (Array<LLM::Function>)
  • :skills (Array<String>)
  • :schema (#to_json)
  • :concurrency (Symbol, Array<Symbol>)
  • :tracer (LLM::Tracer, Proc)
  • :stream (Object, Proc)
  • :confirm (String, Symbol, Array<String, Symbol>, Proc)

Raises:

  • (KeyError) —

    when a property key does not match a class-level accessor



60
61
62
# File 'lib/llm/active_record/acts_as_agent.rb', line 60

def set(properties)
  agent.set(properties)
end