diff --git a/examples/server/public/index.html b/examples/server/public/index.html index 55639a944..a34c8353e 100644 --- a/examples/server/public/index.html +++ b/examples/server/public/index.html @@ -227,6 +227,15 @@ Advanced config
@@ -274,6 +283,7 @@ apiKey: '', systemMessage: 'You are a helpful assistant.', // make sure these default values are in sync with `common.h` + samplers: 'dkypmxt', temperature: 0.8, dynatemp_range: 0.0, dynatemp_exponent: 1.0, @@ -297,6 +307,7 @@ const CONFIG_INFO = { apiKey: '', systemMessage: 'The starting message that defines how model should behave.', + samplers: 'The order at which samplers are applied, in simplified way. Default is "dkypmxt": dry->top_k->typ_p->top_p->min_p->xtc->temperature', temperature: 'Controls the randomness of the generated text by affecting the probability distribution of the output tokens. Higher = more random, lower = more focused.', dynatemp_range: 'Addon for the temperature sampler. The added value to the range of dynamic temperature, which adjusts probabilities by entropy of tokens.', dynatemp_exponent: 'Addon for the temperature sampler. Smoothes out the probability redistribution based on the most probable token.', @@ -525,6 +536,7 @@ ], stream: true, cache_prompt: true, + samplers: this.config.samplers, temperature: this.config.temperature, dynatemp_range: this.config.dynatemp_range, dynatemp_exponent: this.config.dynatemp_exponent, @@ -645,6 +657,11 @@ this.config = {...CONFIG_DEFAULT}; } }, + resetSamplersDialog() { + if (window.confirm('Are you sure to reset seamplers?')) { + this.config.samplers = this.configDefault.samplers; + } + }, // sync state functions fetchConversation() { diff --git a/examples/server/server.cpp b/examples/server/server.cpp index a6d3a1c95..8b458572e 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -916,14 +916,22 @@ struct server_context { { const auto & samplers = data.find("samplers"); - if (samplers != data.end() && samplers->is_array()) { - std::vector sampler_names; - for (const auto & name : *samplers) { - if (name.is_string()) { - sampler_names.emplace_back(name); + if (samplers != data.end()) { + if (samplers->is_array()) { + std::vector sampler_names; + for (const auto & name : *samplers) { + if (name.is_string()) { + sampler_names.emplace_back(name); + } } + slot.sparams.samplers = common_sampler_types_from_names(sampler_names, false); + } else if (samplers->is_string()){ + std::string sampler_string; + for (const auto & name : *samplers) { + sampler_string += name; + } + slot.sparams.samplers = common_sampler_types_from_chars(sampler_string); } - slot.sparams.samplers = common_sampler_types_from_names(sampler_names, false); } else { slot.sparams.samplers = default_sparams.samplers; }