Skip to content

Commit c7f379e

Browse files
committed
fix crash if messages key does not exist
1 parent 7998b11 commit c7f379e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llama.cpp/server/oai.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ inline static json oaicompat_completion_params_parse(
3535
// https://platform.openai.com/docs/api-reference/chat/create
3636
llama_sampling_params default_sparams;
3737
llama_params["model"] = json_value(body, "model", std::string("unknown"));
38-
llama_params["prompt"] = format_chat(model, chat_template, body["messages"]);
38+
llama_params["prompt"] = format_chat(model, chat_template, body.at("messages"));
3939
llama_params["cache_prompt"] = json_value(body, "cache_prompt", false);
4040
llama_params["temperature"] = json_value(body, "temperature", 0.0);
4141
llama_params["top_k"] = json_value(body, "top_k", default_sparams.top_k);

0 commit comments

Comments
 (0)