Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort queryOpenAI parameters #639

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions includes/Jobs/RequestWikiRemoteAIJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ class RequestWikiRemoteAIJob extends Job {
private string $baseApiUrl;
private string $apiKey;

private bool $bio;
private bool $nsfw;
private bool $private;
private int $id;
private string $category;
private string $language;
private string $nsfwtext;
private string $reason;
private string $sitename;
private string $subdomain;
private string $username;
private string $language;
private bool $bio;
private bool $private;
private string $category;
private bool $nsfw;
private string $nsfwtext;

public function __construct(
array $params,
Expand All @@ -57,17 +57,17 @@ public function __construct(
$this->baseApiUrl = 'https://api.openai.com/v1';
$this->apiKey = $this->config->get( ConfigNames::OpenAIConfig )['apikey'] ?? '';

$this->bio = $params['bio'];
$this->category = $params['category'];
$this->id = $params['id'];
$this->language = $params['language'];
$this->nsfw = $params['nsfw'];
$this->nsfwtext = $params['nsfwtext'];
$this->private = $params['private'];
$this->reason = $params['reason'];
$this->sitename = $params['sitename'];
$this->subdomain = $params['subdomain'];
$this->username = $params['username'];
$this->language = $params['language'];
$this->bio = $params['bio'];
$this->private = $params['private'];
$this->category = $params['category'];
$this->nsfw = $params['nsfw'];
$this->nsfwtext = $params['nsfwtext'];
}

public function run(): bool {
Expand Down Expand Up @@ -108,16 +108,16 @@ public function run(): bool {
);

$apiResponse = $this->queryOpenAI(
$this->sitename,
$this->subdomain,
$this->reason,
$this->username,
$this->language,
$this->bio,
$this->private,
$this->category,
$this->language,
$this->nsfw,
$this->nsfwtext
$this->nsfwtext,
$this->private,
$this->reason,
$this->sitename,
$this->subdomain,
$this->username
);

if ( !$apiResponse ) {
Expand Down Expand Up @@ -272,21 +272,21 @@ private function handleLiveRun( string $outcome, string $comment ): bool {
}

private function queryOpenAI(
string $sitename,
string $subdomain,
string $reason,
string $username,
string $language,
bool $bio,
bool $private,
string $category,
string $language,
bool $nsfw,
string $nsfwtext
string $nsfwtext,
bool $private,
string $reason,
string $sitename,
string $subdomain,
string $username
): ?array {
try {
$isBio = $bio ? "Yes" : "No";
$isPrivate = $private ? "Yes" : "No";
$isNsfw = $nsfw ? "Yes" . $nsfwtext : "No";
$isNsfw = $nsfw ? "Yes" : "No";
$nsfwReasonText = $nsfw ? "What type of NSFW content will it feature? '$nsfwtext'. " : "";

$sanitizedReason = "Wiki name: '$sitename'. Subdomain: '$subdomain'. Requester: '$username'. " .
Expand Down
28 changes: 14 additions & 14 deletions includes/Services/WikiRequestManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -983,33 +983,33 @@ private function tryAutoCreate( string $reason ): void {
}

private function evaluateWithOpenAI(
string $sitename,
string $subdomain,
string $reason,
string $username,
string $language,
bool $bio,
bool $nsfw,
bool $private,
string $category,
bool $nsfw,
string $nsfwtext
string $language,
string $nsfwtext,
string $reason,
string $sitename,
string $subdomain,
string $username
): void {
$jobQueueGroup = $this->jobQueueGroupFactory->makeJobQueueGroup();
$jobQueueGroup->push(
new JobSpecification(
RequestWikiRemoteAIJob::JOB_NAME,
[
'id' => $this->ID,
'sitename' => $sitename,
'subdomain' => $subdomain,
'reason' => $reason,
'username' => $username,
'language' => $language,
'bio' => $bio,
'private' => $private,
'category' => $category,
'language' => $language,
'nsfw' => $nsfw,
'nsfwtext' => $nsfwtext
'nsfwtext' => $nsfwtext,
'private' => $private,
'reason' => $reason,
'sitename' => $sitename,
'subdomain' => $subdomain,
'username' => $username
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a trailing comma?

]
)
);
Expand Down
Loading