From 2f804068bd4db03c94e3461d90ee0bb9dc823a8e Mon Sep 17 00:00:00 2001 From: Bruce MacDonald Date: Tue, 12 Mar 2024 19:07:11 -0400 Subject: [PATCH] warn when json format is expected but not mentioned in prompt (#3081) --- llm/dyn_ext_server.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llm/dyn_ext_server.go b/llm/dyn_ext_server.go index e981be94..fd60f1a4 100644 --- a/llm/dyn_ext_server.go +++ b/llm/dyn_ext_server.go @@ -198,6 +198,9 @@ func (llm *dynExtServer) Predict(ctx context.Context, predict PredictOpts, fn fu if predict.Format == "json" { request["grammar"] = jsonGrammar + if !strings.Contains(strings.ToLower(predict.Prompt), "json") { + slog.Warn("Prompt does not specify that the LLM should response in JSON, but JSON format is expected. For best results specify that JSON is expected in the system prompt.") + } } retryDelay := 100 * time.Microsecond