aboutsummaryrefslogtreecommitdiff
path: root/examples/main
diff options
context:
space:
mode:
authorSergey Alirzaev <zl29ah@gmail.com>2023-04-06 17:59:11 +0200
committerGitHub <noreply@github.com>2023-04-06 17:59:11 +0200
commitcc9cee8e9e7598bd280295f6264f36d3a9224006 (patch)
tree28dd4e7715ad1383cb630ca7afd7ed0a11bc4e0c /examples/main
parentd2beca95dcfcd6f1145886e914b879ffc3604b7a (diff)
Do not crash when it has nothing to say. (#796)
Otherwise observing this in the interactive mode: /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/stl_vector.h:1230: reference std::vector<int>::back() [_Tp = int, _Alloc = std::allocator<int>]: Assertion '!this->empty()' failed.
Diffstat (limited to 'examples/main')
-rw-r--r--examples/main/main.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/main/main.cpp b/examples/main/main.cpp
index 453450a..67a34e6 100644
--- a/examples/main/main.cpp
+++ b/examples/main/main.cpp
@@ -431,7 +431,7 @@ int main(int argc, char ** argv) {
}
// end of text token
- if (embd.back() == llama_token_eos()) {
+ if (!embd.empty() && embd.back() == llama_token_eos()) {
if (params.instruct) {
is_interacting = true;
} else {