Skip to content
12 changes: 12 additions & 0 deletions examples/server/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ <h3 class="text-lg font-bold mb-6">Settings</h3>
<summary class="collapse-title font-bold">Advanced config</summary>
<div class="collapse-content">
<label class="form-control mb-2">
<!-- Samplers queue -->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be inside "Other sampler settings"

The "advanced" is mostly for non-sampler stuff I think, like pinning slot number or stop sequence

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw if you merge with latest upstream master branch, you can re-use the settings-modal-short-input component

Copy link
Contributor Author

@MaggotHATE MaggotHATE Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can re-use the settings-modal-short-input component

Thanks, it works! However, the name is automatically set to samplers, which is not very descriptive.

Should I modify settings-modal-short-input to have a separate value for name? UPD: seems to work just fine. It would also allow setting prettier names for sampler parameters later.

<div class="dropdown dropdown-hover">
<div tabindex="0" role="button" class="font">Samplers queue</div>
<div class="dropdown-content menu bg-base-100 rounded-box z-10 p-2 shadow mt-4">
{{ configInfo['samplers'] }}
</div>
</div>
<textarea class="textarea textarea-bordered flex h-12 mb-2" :placeholder="'Default: ' + configDefault.samplers" v-model="config.samplers"></textarea>
<!-- Custom parameters input -->
<div class="label inline">Custom JSON config (For more info, refer to <a class="underline" href="https://github.com/ggerganov/llama.cpp/blob/master/examples/server/README.md" target="_blank" rel="noopener noreferrer">server documentation</a>)</div>
<textarea class="textarea textarea-bordered h-24" placeholder="Example: { &quot;mirostat&quot;: 1, &quot;min_p&quot;: 0.1 }" v-model="config.custom"></textarea>
</label>
Expand Down Expand Up @@ -274,6 +283,7 @@ <h3 class="text-lg font-bold mb-6">Settings</h3>
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,
Expand All @@ -297,6 +307,7 @@ <h3 class="text-lg font-bold mb-6">Settings</h3>
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.',
Expand Down Expand Up @@ -525,6 +536,7 @@ <h3 class="text-lg font-bold mb-6">Settings</h3>
],
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,
Expand Down
20 changes: 14 additions & 6 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,14 +921,22 @@ struct server_context {

{
const auto & samplers = data.find("samplers");
if (samplers != data.end() && samplers->is_array()) {
std::vector<std::string> 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<std::string> 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;
}
Expand Down
Loading