Skip to content

Commit

Permalink
Add basic fields to Special:AI
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardspec committed Dec 7, 2024
1 parent aeb1e34 commit f34af75
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"action-askai": "use [[Special:AI]]",
"askai": "AI",
"askai-desc": "Provides [[Special:AI]], which allows user to make AI queries about content of articles in this wiki.",
"askai-field-pages": "List of wiki pages (and paragraphs in them) to be analyzed by the AI:",
"askai-field-prompt": "Question to ask:",
"askai-field-response": "Response from the AI:",
"right-askai": "Send queries to Special:AI."
}
8 changes: 6 additions & 2 deletions i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
]
},

"action-moderation": "{{doc-action|askai}}",
"action-askai": "{{doc-action|askai}}",
"askai": "Title of the page Special:AI.",
"askai-desc": "{{desc|name=AskAI|url=https://www.mediawiki.org/wiki/Extension:AskAI}}",
"right-askai": "{{doc-right|askai}}\nAllows to use Special:AI."
"askai-field-pages": "Label of field for the list of pages/paragraphs.",
"askai-field-prompt": "Label of field for a question to the AI.:",
"askai-field-response": "Label of readonly field that will show the response from the AI.",
"right-askai": "{{doc-right|askai}}\nAllows to use Special:AI.",
}
17 changes: 15 additions & 2 deletions includes/SpecialAI.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,22 @@ public function requiresWrite() {
/** @inheritDoc */
protected function getFormFields() {
return [
'pagesAndParagraphs' => [
'type' => 'textarea',
'rows' => 5,
'label-message' => 'askai-field-pages',
'required' => true
],
'response' => [
'type' => 'textarea',
'rows' => 10,
'label-message' => 'askai-field-response',
'readonly' => true
],
'prompt' => [
'type' => 'text',
'required' => true,
'label-message' => 'askai-field-prompt',
'required' => true
]
];
}
Expand All @@ -58,7 +71,7 @@ protected function alterForm( HTMLForm $form ) {
/** @inheritDoc */
public function onSubmit( array $data ) {
$ai = ServiceFactory::getAI();
$response = $ai->query( $data['prompt'] );
$response = $ai->query( $data['prompt'], $data['pagesAndParagraphs'] );

$this->getOutput()->addHTML( Xml::element( 'div', [], $response ) );

Expand Down

0 comments on commit f34af75

Please sign in to comment.