diff --git a/i18n/en.json b/i18n/en.json index e8f321542f..47a4fb4a89 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -123,6 +123,7 @@ "requestwiki-error-invalidcomment": "Your wiki request contains an invalid character. Please correct that and try again.", "requestwiki-error-minlength": "Please lengthen this text to $1 {{PLURAL:$1|character|characters}} or more (you are currently using $2 {{PLURAL:$2|character|characters}}).", "requestwiki-error-patient": "You have already requested a wiki! Please be patient, your request is being reviewed. If you need to request another wiki, try again later.", + "requestwiki-header": "Submit a wiki request", "requestwiki-header-comment-withtimestamp": "Comment given by $1 at $2", "requestwiki-info-guidance": "Provide clear and detailed information to help reviewers understand the purpose and scope of your request.", "requestwiki-info-guidance-post": "Thank you for choosing our service!", @@ -152,6 +153,8 @@ "requestwikiqueue-request-info-submission": "Here you can modify the visibility of the request, approve or decline the request, and provide additional comments when doing so. If you mark the wiki as approved, it will be created automatically.", "requestwikiqueue-request-label-action": "What do you want to do?", "requestwikiqueue-request-label-comment": "Comment:", + "requestwikiqueue-request-label-handle-ai": "Handle with AI", + "requestwikiqueue-request-label-handle-ai-success": "This request has been queued for AI evaluation. Check back in a few minutes.", "requestwikiqueue-request-label-language": "Language", "requestwikiqueue-request-label-reason": "Reason for request", "requestwikiqueue-request-label-requested-date": "Requested At", diff --git a/i18n/qqq.json b/i18n/qqq.json index e8489debed..0b9d6214bf 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -130,6 +130,7 @@ "requestwiki-error-invalidcomment": "Invalid comment/character based on disallowed error message.", "requestwiki-error-minlength": "Error message shown when the given reason is too short. $1 is the minlength; $2 is the current length.", "requestwiki-error-patient": "Multiple wiki requests in the same hour error message.\n\nWiki creator is a users with a userright.", + "requestwiki-header": "Legend header for the wiki request form.", "requestwiki-header-comment-withtimestamp": "Timestamp for comment.", "requestwiki-info-guidance": "Introductory guidance text displayed at the top of the wiki request form.", "requestwiki-info-guidance-post": "Additional guidance displayed after the 'reason' field in the wiki request form.", @@ -159,6 +160,8 @@ "requestwikiqueue-request-info-submission": "Instructional text about handling the submission of a wiki request.", "requestwikiqueue-request-label-action": "Label for the 'Action' selection in the request handling form.", "requestwikiqueue-request-label-comment": "Used as a label for 'comment'\n{{Identical|Comment}}", + "requestwikiqueue-request-label-handle-ai": "Label used for 'Handle with AI' button in the request handling form.", + "requestwikiqueue-request-label-handle-ai-success": "Message after a request has been queued for AI handling.", "requestwikiqueue-request-label-language": "Used as a label for 'language'\n{{Identical|Language}}", "requestwikiqueue-request-label-reason": "Label for the 'reason' field in the request details section.", "requestwikiqueue-request-label-requested-date": "Used as a label for 'requested at'.", diff --git a/includes/RequestWiki/Specials/SpecialRequestWiki.php b/includes/RequestWiki/Specials/SpecialRequestWiki.php index 224c2382cd..e675c3ba1a 100644 --- a/includes/RequestWiki/Specials/SpecialRequestWiki.php +++ b/includes/RequestWiki/Specials/SpecialRequestWiki.php @@ -55,7 +55,7 @@ public function execute( $par ): void { 'ext.createwiki.requestwiki.oouiform.styles', ] ); - $form = $this->getForm(); + $form = $this->getForm()->setWrapperLegendMsg( 'requestwiki-header' ); if ( $form && $form->show() ) { $this->onSuccess(); } diff --git a/includes/Services/WikiRequestViewer.php b/includes/Services/WikiRequestViewer.php index a8f86067c2..8cdccc8bb3 100644 --- a/includes/Services/WikiRequestViewer.php +++ b/includes/Services/WikiRequestViewer.php @@ -383,6 +383,18 @@ public function getFormDescriptor(): array { ], ]; + if ( + $this->options->get( ConfigNames::AIConfig )['baseurl'] && + $this->options->get( ConfigNames::AIConfig )['model'] + ) { + $formDescriptor['handle-ai'] = [ + 'type' => 'submit', + 'flags' => [ 'progressive', 'primary' ], + 'buttonlabel-message' => 'requestwikiqueue-request-label-handle-ai', + 'section' => 'handling', + ]; + } + if ( $this->options->get( ConfigNames::CannedResponses ) ) { $formDescriptor['handle-comment']['type'] = 'selectorother'; $formDescriptor['handle-comment']['options'] = $this->options->get( ConfigNames::CannedResponses ); @@ -485,6 +497,13 @@ protected function submitForm( $out = $form->getContext()->getOutput(); $session = $form->getRequest()->getSession(); + if ( isset( $formData['handle-ai'] ) ) { + $this->wikiRequestManager->evaluateWithOllama(); + + $out->addHTML( Html::successBox( $this->context->msg( 'requestwikiqueue-request-label-handle-ai-success' )->escaped() ) ); + return; + } + if ( isset( $formData['submit-comment'] ) ) { // Don't want to mess with some generic comments across requests. // If it is a different request it is not a duplicate comment.