diff --git a/examples/server/server.cpp b/examples/server/server.cpp index 16bcdeda4..cbd8b0035 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -2860,7 +2860,13 @@ int main(int argc, char ** argv) { return; } - json data = oaicompat_completion_params_parse(ctx_server.model, json::parse(req.body), params.chat_template, params.use_jinja); + json data; + try { + data = oaicompat_completion_params_parse(ctx_server.model, json::parse(req.body), params.chat_template, params.use_jinja); + } catch (const std::runtime_error & e) { + res_error(res, format_error_response(e.what(), ERROR_TYPE_NOT_SUPPORTED)); + return; + } std::vector tasks = ctx_server.create_tasks_cmpl(data, SERVER_TASK_CMPL_TYPE_NORMAL); ctx_server.queue_results.add_waiting_tasks(tasks);