@@ -1388,11 +1388,36 @@ public function make_request( $endpoint, $body, $feed ) {
13881388
13891389 switch ( $ endpoint ) {
13901390 case 'chat/completions ' :
1391- $ body ['max_completion_tokens ' ] = (float ) rgar ( $ feed ['meta ' ], $ endpoint . '_ ' . 'max_tokens ' , $ this ->default_settings ['chat/completions ' ]['max_tokens ' ] );
1392- $ body ['temperature ' ] = (float ) rgar ( $ feed ['meta ' ], $ endpoint . '_ ' . 'temperature ' , $ this ->default_settings ['chat/completions ' ]['temperature ' ] );
1393- $ body ['top_p ' ] = (float ) rgar ( $ feed ['meta ' ], $ endpoint . '_ ' . 'top_p ' , $ this ->default_settings ['chat/completions ' ]['top_p ' ] );
1394- $ body ['frequency_penalty ' ] = (float ) rgar ( $ feed ['meta ' ], $ endpoint . '_ ' . 'frequency_penalty ' , $ this ->default_settings ['chat/completions ' ]['frequency_penalty ' ] );
1395- $ body ['presence_penalty ' ] = (float ) rgar ( $ feed ['meta ' ], $ endpoint . '_ ' . 'presence_penalty ' , $ this ->default_settings ['chat/completions ' ]['presence_penalty ' ] );
1391+ $ body ['max_completion_tokens ' ] = (float ) rgar (
1392+ $ feed ['meta ' ],
1393+ $ endpoint . '_max_tokens ' ,
1394+ $ this ->default_settings ['chat/completions ' ]['max_tokens ' ]
1395+ );
1396+
1397+ // temperature is deprecated in certain models, so only set if the user has set an explicit value.
1398+ $ temperature = rgar ( $ feed ['meta ' ], $ endpoint . '_temperature ' );
1399+ if ( $ temperature !== null && $ temperature !== '' ) {
1400+ $ body ['temperature ' ] = (float ) $ temperature ;
1401+ }
1402+
1403+ // top_p is deprecated in certain models, so only set if the user has set an explicit value.
1404+ $ top_p = rgar ( $ feed ['meta ' ], $ endpoint . '_top_p ' );
1405+ if ( $ top_p !== null && $ top_p !== '' ) {
1406+ $ body ['top_p ' ] = (float ) $ top_p ;
1407+ }
1408+
1409+ // frequency_penalty is deprecated in certain models, so only set if the user has set an explicit value.
1410+ $ frequency_penalty = rgar ( $ feed ['meta ' ], $ endpoint . '_frequency_penalty ' );
1411+ if ( $ frequency_penalty !== null && $ frequency_penalty !== '' ) {
1412+ $ body ['frequency_penalty ' ] = (float ) $ frequency_penalty ;
1413+ }
1414+
1415+ // presence_penalty is deprecated in certain models, so only set if the user has set an explicit value.
1416+ $ presence_penalty = rgar ( $ feed ['meta ' ], $ endpoint . '_presence_penalty ' );
1417+ if ( $ presence_penalty !== null && $ presence_penalty !== '' ) {
1418+ $ body ['presence_penalty ' ] = (float ) $ presence_penalty ;
1419+ }
1420+
13961421 break ;
13971422 }
13981423
0 commit comments