-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide DebugService for convenient testing
Because OpenAI service has already been tested and works, and because part of $instructions won't be shown to the user, there is no point in using the real service during development. Instead, DebugService will print both $prompt and $instructions as response to any query.
- Loading branch information
1 parent
f34af75
commit dce5d2f
Showing
7 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* Implements AskAI extension for MediaWiki. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* http://www.gnu.org/copyleft/gpl.html | ||
* | ||
* @file | ||
*/ | ||
|
||
namespace MediaWiki\AskAI\Service; | ||
|
||
/** | ||
* Fake service that responds to any prompts with "What did the user request?" information. | ||
*/ | ||
class DebugService implements IExternalService { | ||
/** | ||
* Send an arbitrary question to ChatGPT and return the response. | ||
* @param string $prompt Question to ask. | ||
* @param string $instructions Preferences on how to respond, e.g. "You are a research assistant". | ||
* @return string | ||
*/ | ||
public function query( $prompt, $instructions = '' ) { | ||
$delim = str_repeat( '-', 80 ); | ||
$response = wfMessage( 'askai-debug-header' )->plain() . "\n\n" . | ||
wfMessage( 'askai-debug-prompt' )->plain() . | ||
"\n$delim\n$prompt\n$delim\n\n" . | ||
wfMessage( 'askai-debug-instructions' )->plain() . | ||
"\n$delim\n$instructions\n$delim"; | ||
|
||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters