Class: Assistant::TechnicalArticleManagementToolBuilder::TransitionRevisionTool
- Inherits:
-
ManagementTool
- Object
- RubyLLM::Tool
- ManagementTool
- Assistant::TechnicalArticleManagementToolBuilder::TransitionRevisionTool
- Defined in:
- app/services/assistant/technical_article_management_tool_builder.rb
Overview
Moves an ArticleRevision proposal through review and applies approval to
the same live Article identity.
Constant Summary collapse
- EVENTS =
%w[submit_for_review request_changes approve reject].freeze
Instance Method Summary collapse
-
#execute(id:, revision_id:, event:, review_notes: nil, confirm: false) ⇒ String
Moves a proposal through submission, review, or approval.
-
#name ⇒ String
Stable tool name.
Methods inherited from ManagementTool
Constructor Details
This class inherits a constructor from Assistant::TechnicalArticleManagementToolBuilder::ManagementTool
Instance Method Details
#execute(id:, revision_id:, event:, review_notes: nil, confirm: false) ⇒ String
Moves a proposal through submission, review, or approval.
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'app/services/assistant/technical_article_management_tool_builder.rb', line 514 def execute(id:, revision_id:, event:, review_notes: nil, confirm: false, **) safely('transition revision') do article = find_article!(id) event = event.to_s raise ToolError, "Unknown revision event: #{event}." unless event.in?(EVENTS) action = event == 'submit_for_review' ? :update : :approve (action, article) revision = find_revision!(article, revision_id) case event when 'submit_for_review' revision.submit_for_review! when 'request_changes' revision.request_changes_by!(reviewer: require_actor!, notes: review_notes) when 'reject' revision.reject_by!(reviewer: require_actor!, notes: review_notes) when 'approve' raise ToolError, "Set confirm=true to apply revision ##{revision.id} to Article ##{article.id}." unless confirm == true result = ArticleRevision::Approval.call( revision: revision, reviewer: require_actor!, review_notes: review_notes ) raise ToolError, result.errors.to_sentence unless result.success? end revision_response( article.reload, revision.reload, { transition: event, message: ('The existing Article was updated in place; its ID and slug are unchanged.' if event == 'approve') } ) end end |
#name ⇒ String
Returns stable tool name.
504 |
# File 'app/services/assistant/technical_article_management_tool_builder.rb', line 504 def name = 'transition_technical_article_revision' |