Skip to content

Commit 225c438

Browse files
committed
~ Fixed issue with deprecated params in GPT-5 level models.
1 parent 179e2ff commit 225c438

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

class-gwiz-gf-openai.php

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,11 +1385,36 @@ public function make_request( $endpoint, $body, $feed ) {
13851385

13861386
switch ( $endpoint ) {
13871387
case 'chat/completions':
1388-
$body['max_completion_tokens'] = (float) rgar( $feed['meta'], $endpoint . '_' . 'max_tokens', $this->default_settings['chat/completions']['max_tokens'] );
1389-
$body['temperature'] = (float) rgar( $feed['meta'], $endpoint . '_' . 'temperature', $this->default_settings['chat/completions']['temperature'] );
1390-
$body['top_p'] = (float) rgar( $feed['meta'], $endpoint . '_' . 'top_p', $this->default_settings['chat/completions']['top_p'] );
1391-
$body['frequency_penalty'] = (float) rgar( $feed['meta'], $endpoint . '_' . 'frequency_penalty', $this->default_settings['chat/completions']['frequency_penalty'] );
1392-
$body['presence_penalty'] = (float) rgar( $feed['meta'], $endpoint . '_' . 'presence_penalty', $this->default_settings['chat/completions']['presence_penalty'] );
1388+
$body['max_completion_tokens'] = (float) rgar(
1389+
$feed['meta'],
1390+
$endpoint . '_max_tokens',
1391+
$this->default_settings['chat/completions']['max_tokens']
1392+
);
1393+
1394+
// temperature is deprecated in certain models, so only set if the user has set an explicit value.
1395+
$temperature = rgar( $feed['meta'], $endpoint . '_temperature' );
1396+
if ( $temperature !== null && $temperature !== '' ) {
1397+
$body['temperature'] = (float) $temperature;
1398+
}
1399+
1400+
// top_p is deprecated in certain models, so only set if the user has set an explicit value.
1401+
$top_p = rgar( $feed['meta'], $endpoint . '_top_p' );
1402+
if ( $top_p !== null && $top_p !== '' ) {
1403+
$body['top_p'] = (float) $top_p;
1404+
}
1405+
1406+
// frequency_penalty is deprecated in certain models, so only set if the user has set an explicit value.
1407+
$frequency_penalty = rgar( $feed['meta'], $endpoint . '_frequency_penalty' );
1408+
if ( $frequency_penalty !== null && $frequency_penalty !== '' ) {
1409+
$body['frequency_penalty'] = (float) $frequency_penalty;
1410+
}
1411+
1412+
// presence_penalty is deprecated in certain models, so only set if the user has set an explicit value.
1413+
$presence_penalty = rgar( $feed['meta'], $endpoint . '_presence_penalty' );
1414+
if ( $presence_penalty !== null && $presence_penalty !== '' ) {
1415+
$body['presence_penalty'] = (float) $presence_penalty;
1416+
}
1417+
13931418
break;
13941419
}
13951420

0 commit comments

Comments
 (0)