Class: ActionAI::ExecutionJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/action_ai/execution_job.rb

Overview

Action AI ExecutionJob

The ActionAI::ExecutionJob class is used when you want to execute AI-powered jobs outside of the request-response cycle. It supports executing either parameterized or normal actions.

Exceptions are rescued and handled by the agent class.

Instance Method Summary collapse

Instance Method Details

#perform(agent, action, args: [], kwargs: {}, params: nil) ⇒ Object



21
22
23
24
25
26
# File 'lib/action_ai/execution_job.rb', line 21

def perform(agent, action, args: [], kwargs: {}, params: nil)
  agent.constantize
    .then { params ? it.with(params) : it }
    .public_send(action, *args, **kwargs)
    .run
end