Class: Collavre::OpenclawAbortService
- Inherits:
-
Object
- Object
- Collavre::OpenclawAbortService
- Defined in:
- app/services/collavre/openclaw_abort_service.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(agent:, task:, creative: nil, comment: nil) ⇒ OpenclawAbortService
constructor
A new instance of OpenclawAbortService.
Constructor Details
#initialize(agent:, task:, creative: nil, comment: nil) ⇒ OpenclawAbortService
Returns a new instance of OpenclawAbortService.
9 10 11 12 13 14 |
# File 'app/services/collavre/openclaw_abort_service.rb', line 9 def initialize(agent:, task:, creative: nil, comment: nil) @agent = agent @task = task @creative = creative @comment = comment end |
Class Method Details
.call(agent:, task:, creative: nil, comment: nil) ⇒ Object
5 6 7 |
# File 'app/services/collavre/openclaw_abort_service.rb', line 5 def self.call(agent:, task:, creative: nil, comment: nil) new(agent: agent, task: task, creative: creative, comment: comment).call end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/services/collavre/openclaw_abort_service.rb', line 16 def call return unless @agent.llm_vendor&.downcase == "openclaw" return unless defined?(CollavreOpenclaw::ConnectionManager) creative = @creative || @task.creative || Creative.find_by(id: payload.dig("creative", "id")) comment = @comment || Comment.find_by(id: payload.dig("comment", "id")) adapter = CollavreOpenclaw::OpenclawAdapter.new( user: @agent, system_prompt: "", context: { creative: creative, user: @agent, task: @task, comment: comment } ) conn = CollavreOpenclaw::ConnectionManager.instance.connection_for(@agent) conn.chat_abort(session_key: adapter.session_key) rescue StandardError => e Rails.logger.warn("[OpenclawAbortService] abort failed: #{e.}") end |