8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/jobs/rcrewai/rails/crew_execution_job.rb', line 8
def perform(crew, inputs = {})
execution = crew.executions.create!(
status: "pending",
inputs: inputs
)
begin
execution.start!
execution.log("info", "Starting crew execution", { crew_id: crew.id, inputs: inputs })
rcrew = crew.to_rcrew
result = rcrew.execute(stream: stream_sink_for(execution))
execution.complete!(result)
execution.log("info", "Crew execution completed", { result: result })
notify_completion(crew, execution, result)
result
rescue => e
execution.fail!(e)
execution.log("error", "Crew execution failed", {
error: e.message,
backtrace: e.backtrace&.first(5)
})
raise
end
end
|