Class: ActiveAgent::GenerationJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/active_agent/generation_job.rb

Overview

Active Agent GenerationJob

The ActiveAgent::GenerationJob class is used when you want to generate content outside of the request-response cycle. It supports sending messages with parameters.

Exceptions are rescued and handled by the agent class.

Instance Method Summary collapse

Instance Method Details

#perform(agent_class_name, action_name, args:, params: nil) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/active_agent/generation_job.rb', line 21

def perform(agent_class_name, action_name, args:, params: nil)
  agent_class = agent_class_name.constantize
  agent = agent_class.new
  agent.params = params if params
  agent.process(action_name, *args)
  agent.generate
end