Add seed input field for OpenAI settings #1412
This commit is contained in:
parent
6abd0b4b75
commit
e9ad55aef2
|
@ -737,6 +737,17 @@
|
||||||
<div id="openai_proxy_password_show" title="Peek a password" class="menu_button fa-solid fa-eye-slash fa-fw"></div>
|
<div id="openai_proxy_password_show" title="Peek a password" class="menu_button fa-solid fa-eye-slash fa-fw"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div data-newbie-hidden class="range-block" data-source="openai,openrouter">
|
||||||
|
<div class="range-block-title justifyLeft" data-i18n="Seed">
|
||||||
|
Seed
|
||||||
|
</div>
|
||||||
|
<div class="toggle-description justifyLeft" data-i18n="Set to get deterministic results. Use -1 for random seed.">
|
||||||
|
Set to get deterministic results. Use -1 for random seed.
|
||||||
|
</div>
|
||||||
|
<div class="wide100p">
|
||||||
|
<input type="number" id="seed_openai" name="seed_openai" class="text_pole" min="-1" max="2147483647" value="-1">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div data-newbie-hidden class="range-block" data-source="openai,claude">
|
<div data-newbie-hidden class="range-block" data-source="openai,claude">
|
||||||
<div class="range-block-title justifyLeft">
|
<div class="range-block-title justifyLeft">
|
||||||
<label for="legacy_streaming" class="checkbox_label">
|
<label for="legacy_streaming" class="checkbox_label">
|
||||||
|
|
|
@ -229,6 +229,7 @@ const default_settings = {
|
||||||
squash_system_messages: false,
|
squash_system_messages: false,
|
||||||
image_inlining: false,
|
image_inlining: false,
|
||||||
bypass_status_check: false,
|
bypass_status_check: false,
|
||||||
|
seed: -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const oai_settings = {
|
const oai_settings = {
|
||||||
|
@ -282,6 +283,7 @@ const oai_settings = {
|
||||||
squash_system_messages: false,
|
squash_system_messages: false,
|
||||||
image_inlining: false,
|
image_inlining: false,
|
||||||
bypass_status_check: false,
|
bypass_status_check: false,
|
||||||
|
seed: -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
let openai_setting_names;
|
let openai_setting_names;
|
||||||
|
@ -1557,6 +1559,10 @@ async function sendOpenAIRequest(type, messages, signal) {
|
||||||
generate_data['stop_tokens'] = [name1 + ':', oai_settings.new_chat_prompt, oai_settings.new_group_chat_prompt];
|
generate_data['stop_tokens'] = [name1 + ':', oai_settings.new_chat_prompt, oai_settings.new_group_chat_prompt];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((isOAI || isOpenRouter) && oai_settings.seed >= 0) {
|
||||||
|
generate_data['seed'] = oai_settings.seed;
|
||||||
|
}
|
||||||
|
|
||||||
const generate_url = '/generate_openai';
|
const generate_url = '/generate_openai';
|
||||||
const response = await fetch(generate_url, {
|
const response = await fetch(generate_url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -2415,6 +2421,7 @@ function loadOpenAISettings(data, settings) {
|
||||||
|
|
||||||
$('#top_k_openai').val(oai_settings.top_k_openai);
|
$('#top_k_openai').val(oai_settings.top_k_openai);
|
||||||
$('#top_k_counter_openai').val(Number(oai_settings.top_k_openai).toFixed(0));
|
$('#top_k_counter_openai').val(Number(oai_settings.top_k_openai).toFixed(0));
|
||||||
|
$('#seed_openai').val(oai_settings.seed);
|
||||||
|
|
||||||
if (settings.reverse_proxy !== undefined) oai_settings.reverse_proxy = settings.reverse_proxy;
|
if (settings.reverse_proxy !== undefined) oai_settings.reverse_proxy = settings.reverse_proxy;
|
||||||
$('#openai_reverse_proxy').val(oai_settings.reverse_proxy);
|
$('#openai_reverse_proxy').val(oai_settings.reverse_proxy);
|
||||||
|
@ -2594,6 +2601,7 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
||||||
use_alt_scale: settings.use_alt_scale,
|
use_alt_scale: settings.use_alt_scale,
|
||||||
squash_system_messages: settings.squash_system_messages,
|
squash_system_messages: settings.squash_system_messages,
|
||||||
image_inlining: settings.image_inlining,
|
image_inlining: settings.image_inlining,
|
||||||
|
seed: settings.seed,
|
||||||
};
|
};
|
||||||
|
|
||||||
const savePresetSettings = await fetch(`/api/presets/save-openai?name=${name}`, {
|
const savePresetSettings = await fetch(`/api/presets/save-openai?name=${name}`, {
|
||||||
|
@ -2953,6 +2961,7 @@ function onSettingsPresetChange() {
|
||||||
use_alt_scale: ['#use_alt_scale', 'use_alt_scale', true],
|
use_alt_scale: ['#use_alt_scale', 'use_alt_scale', true],
|
||||||
squash_system_messages: ['#squash_system_messages', 'squash_system_messages', true],
|
squash_system_messages: ['#squash_system_messages', 'squash_system_messages', true],
|
||||||
image_inlining: ['#openai_image_inlining', 'image_inlining', true],
|
image_inlining: ['#openai_image_inlining', 'image_inlining', true],
|
||||||
|
seed: ['#seed_openai', 'seed', false],
|
||||||
};
|
};
|
||||||
|
|
||||||
const presetName = $('#settings_preset_openai').find(":selected").text();
|
const presetName = $('#settings_preset_openai').find(":selected").text();
|
||||||
|
@ -3768,6 +3777,11 @@ $(document).ready(async function () {
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#seed_openai').on('input', function () {
|
||||||
|
oai_settings.seed = Number($(this).val());
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
|
||||||
$(document).on('input', '#openai_settings .autoSetHeight', function () {
|
$(document).on('input', '#openai_settings .autoSetHeight', function () {
|
||||||
resetScrollHeight($(this));
|
resetScrollHeight($(this));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3303,6 +3303,7 @@ app.post("/generate_openai", jsonParser, function (request, response_generate_op
|
||||||
"top_k": request.body.top_k,
|
"top_k": request.body.top_k,
|
||||||
"stop": isTextCompletion === false ? request.body.stop : undefined,
|
"stop": isTextCompletion === false ? request.body.stop : undefined,
|
||||||
"logit_bias": request.body.logit_bias,
|
"logit_bias": request.body.logit_bias,
|
||||||
|
"seed": request.body.seed,
|
||||||
...bodyParams,
|
...bodyParams,
|
||||||
}),
|
}),
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
|
|
Loading…
Reference in New Issue