Skip to content

Commit 59ba76c

Browse files
committed
server: support sampling method arg
1 parent 0f81cfb commit 59ba76c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

examples/server/main.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,18 @@ void parseJsonPrompt(std::string json_str, SDParams* params) {
628628
}
629629
try {
630630
std::string sample_method = payload["sample_method"];
631-
// TODO map to enum value
632-
// LOG_WARN("sample_method is not supported yet\n");
633-
sd_log(sd_log_level_t::SD_LOG_WARN, "sample_method is not supported yet\n");
631+
632+
int sample_method_found = -1;
633+
for (int m = 0; m < N_SAMPLE_METHODS; m++) {
634+
if (!strcmp(sample_method.c_str(), sample_method_str[m])) {
635+
sample_method_found = m;
636+
}
637+
}
638+
if (sample_method_found >= 0) {
639+
params->sample_method = (sample_method_t)sample_method_found;
640+
} else {
641+
sd_log(sd_log_level_t::SD_LOG_WARN, "Unknown sampling method: %s\n", sample_method.c_str());
642+
}
634643
} catch (...) {
635644
}
636645
try {

0 commit comments

Comments
 (0)