From 04314765f2b3163646b7804e87742489bd96fc24 Mon Sep 17 00:00:00 2001 From: jmorganca Date: Tue, 17 Dec 2024 09:16:01 -0800 Subject: [PATCH] llm: consider null format same as empty value --- llm/server.go | 2 +- llm/server_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/llm/server.go b/llm/server.go index 832863720..2501b5a33 100644 --- a/llm/server.go +++ b/llm/server.go @@ -701,7 +701,7 @@ func (s *llmServer) Completion(ctx context.Context, req CompletionRequest, fn fu if len(req.Format) > 0 { switch { - case bytes.Equal(req.Format, []byte(`""`)): + case bytes.Equal(req.Format, []byte(`""`)) || bytes.Equal(req.Format, []byte(`null`)): // fallthrough case bytes.Equal(req.Format, []byte(`"json"`)): request["grammar"] = grammarJSON diff --git a/llm/server_test.go b/llm/server_test.go index e6f79a585..66a2b7d6a 100644 --- a/llm/server_test.go +++ b/llm/server_test.go @@ -46,7 +46,7 @@ func TestLLMServerCompletionFormat(t *testing.T) { } } - valids := []string{`"json"`, `{"type":"object"}`, ``, `""`} + valids := []string{`"json"`, `{"type":"object"}`, ``, `""`, `null`} for _, valid := range valids { err := s.Completion(ctx, CompletionRequest{ Options: new(api.Options),