Class: RcrewAI::Rails::Api::V1::CrewsController

Inherits:
RcrewAI::Rails::ApplicationController show all
Defined in:
app/controllers/rcrewai/rails/api/v1/crews_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
# File 'app/controllers/rcrewai/rails/api/v1/crews_controller.rb', line 18

def create
  @crew = Crew.new(crew_params)
  
  if @crew.save
    render json: @crew, status: :created
  else
    render json: { errors: @crew.errors }, status: :unprocessable_entity
  end
end

#executeObject



28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/rcrewai/rails/api/v1/crews_controller.rb', line 28

def execute
  inputs = params[:inputs] || {}
  execution = @crew.execute_async(inputs)
  
  render json: {
    execution_id: execution.id,
    status: execution.status,
    message: 'Crew execution started successfully'
  }
end

#indexObject



9
10
11
12
# File 'app/controllers/rcrewai/rails/api/v1/crews_controller.rb', line 9

def index
  @crews = Crew.includes(:agents, :tasks).all
  render json: @crews.as_json(include: [:agents, :tasks])
end

#showObject



14
15
16
# File 'app/controllers/rcrewai/rails/api/v1/crews_controller.rb', line 14

def show
  render json: @crew.as_json(include: [:agents, :tasks, :executions])
end