Skip to content

Distribute and run LLMs with a single file.

fix crash if messages key does not exist

CJ Paisc7f379e2502c
diff --git a/llama.cpp/server/oai.h b/llama.cpp/server/oai.h
index 949e72b2..b82ef25d 100644
--- a/llama.cpp/server/oai.h
+++ b/llama.cpp/server/oai.h
@@ -35,7 +35,7 @@ inline static json oaicompat_completion_params_parse(
// https://platform.openai.com/docs/api-reference/chat/create
llama_sampling_params default_sparams;
llama_params["model"] = json_value(body, "model", std::string("unknown"));
- llama_params["prompt"] = format_chat(model, chat_template, body["messages"]);
+ llama_params["prompt"] = format_chat(model, chat_template, body.at("messages"));
llama_params["cache_prompt"] = json_value(body, "cache_prompt", false);
llama_params["temperature"] = json_value(body, "temperature", 0.0);
llama_params["top_k"] = json_value(body, "top_k", default_sparams.top_k);