Update examples/server/server.cpp

Co-authored-by: compilade <git@compilade.net>
This commit is contained in:
Justine Tunney 2024-05-22 01:11:38 -07:00 committed by GitHub
parent a94895217c
commit 8be06dc745
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2258,7 +2258,12 @@ struct server_context {
completion_token_output result; completion_token_output result;
const llama_token id = llama_sampling_sample(slot.ctx_sampling, ctx, NULL, slot.i_batch - i); const llama_token id = llama_sampling_sample(slot.ctx_sampling, ctx, NULL, slot.i_batch - i);
if (id == -1) { if (id == -1) {
continue; // keep going, don't crash, already logged send_error(slot, "can't get completions out of an embeddings model");
slot.cache_tokens.clear();
slot.reset();
slot.release();
slot.i_batch = -1;
continue; // continue loop of slots
} }
llama_sampling_accept(slot.ctx_sampling, ctx, id, true); llama_sampling_accept(slot.ctx_sampling, ctx, id, true);