Skip to content

Commit 357923e

Browse files
SoftwareRendererolexiyb
authored andcommitted
server : relay error messages (ggml-org#4131)
1 parent ffa4543 commit 357923e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

examples/server/public/completion.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ export async function* llama(prompt, params = {}, config = {}) {
9494
break;
9595
}
9696
}
97+
if (result.error) {
98+
result.error = JSON.parse(result.error);
99+
console.error(`llama.cpp error: ${result.error.content}`);
100+
}
97101
}
98102
}
99103
}

examples/server/server.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,6 +2371,17 @@ int main(int argc, char **argv)
23712371
break;
23722372
}
23732373
} else {
2374+
const std::string str =
2375+
"error: " +
2376+
result.result_json.dump(-1, ' ', false, json::error_handler_t::replace) +
2377+
"\n\n";
2378+
LOG_VERBOSE("data stream", {
2379+
{ "to_send", str }
2380+
});
2381+
if (!sink.write(str.c_str(), str.size()))
2382+
{
2383+
return false;
2384+
}
23742385
break;
23752386
}
23762387
}

0 commit comments

Comments
 (0)