Class: RcrewAI::Rails::Task

Inherits:
ApplicationRecord show all
Defined in:
app/models/rcrewai/rails/task.rb

Instance Method Summary collapse

Instance Method Details

#add_dependency(other_task) ⇒ Object



45
46
47
# File 'app/models/rcrewai/rails/task.rb', line 45

def add_dependency(other_task)
  task_dependencies.create!(dependency: other_task)
end

#instantiated_toolsObject



35
36
37
38
39
40
41
42
43
# File 'app/models/rcrewai/rails/task.rb', line 35

def instantiated_tools
  return [] if tools.blank?

  tools.map do |tool_config|
    tool_class = tool_config["class"].constantize
    tool_params = tool_config["params"] || {}
    tool_class.new(**tool_params.symbolize_keys)
  end
end

#remove_dependency(other_task) ⇒ Object



49
50
51
# File 'app/models/rcrewai/rails/task.rb', line 49

def remove_dependency(other_task)
  task_dependencies.where(dependency: other_task).destroy_all
end

#to_rcrew_taskObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/rcrewai/rails/task.rb', line 21

def to_rcrew_task
  RCrewAI::Task.new(
    name: rcrew_task_name,
    description: description,
    expected_output: expected_output,
    agent: agent&.to_rcrew_agent,
    context: context,
    async: async_execution,
    tools: instantiated_tools,
    callback: callback_method
  )
end