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),