MDL-85967 aiprovider_openai: Update param max_completion_tokens
AMOS BEGIN MOV [settings_max_tokens_help,aiprovider_openai],[settings_max_completion_tokens_help,aiprovider_openai] AMOS END
This commit is contained in:
@@ -55,11 +55,11 @@ class gpt4o extends base implements openai_base {
|
||||
|
||||
$mform->addElement(
|
||||
'text',
|
||||
'max_tokens',
|
||||
get_string('settings_max_tokens', 'aiprovider_openai'),
|
||||
'max_completion_tokens',
|
||||
get_string('settings_max_completion_tokens', 'aiprovider_openai'),
|
||||
);
|
||||
$mform->setType('max_tokens', PARAM_INT);
|
||||
$mform->addHelpButton('max_tokens', 'settings_max_tokens', 'aiprovider_openai');
|
||||
$mform->setType('max_completion_tokens', PARAM_INT);
|
||||
$mform->addHelpButton('max_completion_tokens', 'settings_max_completion_tokens', 'aiprovider_openai');
|
||||
|
||||
$mform->addElement(
|
||||
'text',
|
||||
|
||||
@@ -48,7 +48,7 @@ $string['extraparams_help'] = 'Extra parameters can be configured here. We suppo
|
||||
<pre>
|
||||
{
|
||||
"temperature": 0.5,
|
||||
"max_tokens": 100
|
||||
"max_completion_tokens": 100
|
||||
}
|
||||
</pre>';
|
||||
$string['invalidjson'] = 'Invalid JSON string';
|
||||
@@ -65,8 +65,8 @@ $string['settings'] = 'Settings';
|
||||
$string['settings_frequency_penalty'] = 'frequency_penalty';
|
||||
$string['settings_frequency_penalty_help'] = 'The frequency penalty adjusts how often words are repeated. The higher the penalty, the less repetitions in the generated text.';
|
||||
$string['settings_help'] = 'Adjust the settings below to customise how requests are sent to OpenAI.';
|
||||
$string['settings_max_tokens'] = 'max_tokens';
|
||||
$string['settings_max_tokens_help'] = 'The maximum number of tokens used in the generated text.';
|
||||
$string['settings_max_completion_tokens'] = 'max_completion_tokens';
|
||||
$string['settings_max_completion_tokens_help'] = 'The maximum number of tokens used in the generated text.';
|
||||
$string['settings_presence_penalty'] = 'presence_penalty';
|
||||
$string['settings_presence_penalty_help'] = 'The presence penalty encourages the model to use new words by increasing the likelihood of choosing words it hasn\'t used before. A higher value makes the generated text more diverse, while a lower value allows more repetition.';
|
||||
$string['settings_top_p'] = 'top_p';
|
||||
@@ -88,3 +88,5 @@ $string['globalratelimit_desc'] = 'The number of site-wide requests allowed per
|
||||
$string['orgid_desc'] = 'Get an OpenAI organization ID from your <a href="https://platform.openai.com/account/org-settings">OpenAI Platform account</a>.';
|
||||
$string['userratelimit'] = 'Maximum number of requests per user';
|
||||
$string['userratelimit_desc'] = 'The number of requests allowed per hour, per user.';
|
||||
$string['settings_max_tokens'] = 'max_tokens';
|
||||
$string['settings_max_tokens_help'] = 'The maximum number of tokens used in the generated text.';
|
||||
|
||||
@@ -13,3 +13,5 @@ globalratelimit_desc,aiprovider_openai
|
||||
orgid_desc,aiprovider_openai
|
||||
userratelimit,aiprovider_openai
|
||||
userratelimit_desc,aiprovider_openai
|
||||
settings_max_tokens,aiprovider_openai
|
||||
settings_max_tokens_help,aiprovider_openai
|
||||
|
||||
@@ -132,7 +132,7 @@ final class process_generate_image_test extends \advanced_testcase {
|
||||
actionconfig: [
|
||||
'model' => 'dall-e-3',
|
||||
'temperature' => '0.5',
|
||||
'max_tokens' => '100',
|
||||
'max_completion_tokens' => '100',
|
||||
],
|
||||
);
|
||||
$processor = new process_generate_image($this->provider, $this->action);
|
||||
@@ -145,13 +145,13 @@ final class process_generate_image_test extends \advanced_testcase {
|
||||
|
||||
$this->assertEquals('dall-e-3', $body->model);
|
||||
$this->assertEquals('0.5', $body->temperature);
|
||||
$this->assertEquals('100', $body->max_tokens);
|
||||
$this->assertEquals('100', $body->max_completion_tokens);
|
||||
|
||||
$this->provider = $this->create_provider(
|
||||
actionclass: \core_ai\aiactions\generate_image::class,
|
||||
actionconfig: [
|
||||
'model' => 'my-custom-gpt',
|
||||
'modelextraparams' => '{"temperature": 0.5,"max_tokens": 100}',
|
||||
'modelextraparams' => '{"temperature": 0.5,"max_completion_tokens": 100}',
|
||||
],
|
||||
);
|
||||
$processor = new process_generate_image($this->provider, $this->action);
|
||||
@@ -164,7 +164,7 @@ final class process_generate_image_test extends \advanced_testcase {
|
||||
|
||||
$this->assertEquals('my-custom-gpt', $body->model);
|
||||
$this->assertEquals('0.5', $body->temperature);
|
||||
$this->assertEquals('100', $body->max_tokens);
|
||||
$this->assertEquals('100', $body->max_completion_tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,7 +102,7 @@ final class process_generate_text_test extends \advanced_testcase {
|
||||
actionconfig: [
|
||||
'systeminstruction' => get_string('action_generate_text_instruction', 'core_ai'),
|
||||
'temperature' => '0.5',
|
||||
'max_tokens' => '100',
|
||||
'max_completion_tokens' => '100',
|
||||
],
|
||||
);
|
||||
$processor = new process_generate_text($this->provider, $this->action);
|
||||
@@ -115,14 +115,14 @@ final class process_generate_text_test extends \advanced_testcase {
|
||||
|
||||
$this->assertEquals('gpt-4o', $body->model);
|
||||
$this->assertEquals('0.5', $body->temperature);
|
||||
$this->assertEquals('100', $body->max_tokens);
|
||||
$this->assertEquals('100', $body->max_completion_tokens);
|
||||
|
||||
$this->provider = $this->create_provider(
|
||||
actionclass: \core_ai\aiactions\generate_text::class,
|
||||
actionconfig: [
|
||||
'model' => 'my-custom-gpt',
|
||||
'systeminstruction' => get_string('action_generate_text_instruction', 'core_ai'),
|
||||
'modelextraparams' => '{"temperature": 0.5,"max_tokens": 100}',
|
||||
'modelextraparams' => '{"temperature": 0.5,"max_completion_tokens": 100}',
|
||||
],
|
||||
);
|
||||
$processor = new process_generate_text($this->provider, $this->action);
|
||||
@@ -135,7 +135,7 @@ final class process_generate_text_test extends \advanced_testcase {
|
||||
|
||||
$this->assertEquals('my-custom-gpt', $body->model);
|
||||
$this->assertEquals('0.5', $body->temperature);
|
||||
$this->assertEquals('100', $body->max_tokens);
|
||||
$this->assertEquals('100', $body->max_completion_tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,7 +104,7 @@ final class process_summarise_text_test extends \advanced_testcase {
|
||||
actionconfig: [
|
||||
'systeminstruction' => get_string('action_summarise_text_instruction', 'core_ai'),
|
||||
'temperature' => '0.5',
|
||||
'max_tokens' => '100',
|
||||
'max_completion_tokens' => '100',
|
||||
],
|
||||
);
|
||||
$processor = new process_summarise_text($this->provider, $this->action);
|
||||
@@ -117,14 +117,14 @@ final class process_summarise_text_test extends \advanced_testcase {
|
||||
|
||||
$this->assertEquals('gpt-4o', $body->model);
|
||||
$this->assertEquals('0.5', $body->temperature);
|
||||
$this->assertEquals('100', $body->max_tokens);
|
||||
$this->assertEquals('100', $body->max_completion_tokens);
|
||||
|
||||
$this->provider = $this->create_provider(
|
||||
actionclass: \core_ai\aiactions\summarise_text::class,
|
||||
actionconfig: [
|
||||
'model' => 'my-custom-gpt',
|
||||
'systeminstruction' => get_string('action_summarise_text_instruction', 'core_ai'),
|
||||
'modelextraparams' => '{"temperature": 0.5,"max_tokens": 100}',
|
||||
'modelextraparams' => '{"temperature": 0.5,"max_completion_tokens": 100}',
|
||||
],
|
||||
);
|
||||
$processor = new process_summarise_text($this->provider, $this->action);
|
||||
@@ -137,7 +137,7 @@ final class process_summarise_text_test extends \advanced_testcase {
|
||||
|
||||
$this->assertEquals('my-custom-gpt', $body->model);
|
||||
$this->assertEquals('0.5', $body->temperature);
|
||||
$this->assertEquals('100', $body->max_tokens);
|
||||
$this->assertEquals('100', $body->max_completion_tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user