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

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

Instance Method Summary collapse

Instance Method Details

#agentClass<LLM::Agent>

Returns:



22
23
24
# File 'lib/llm/active_record/acts_as_agent.rb', line 22

def agent
  @agent ||= Class.new(LLM::Agent)
end

#set(properties) ⇒ void

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: [Shell]
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



52
53
54
# File 'lib/llm/active_record/acts_as_agent.rb', line 52

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