mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-11 00:07:07 +00:00
llm: do not error on "null" format (#8139)
This fixes another regression in the previous commit that fixed other known bugs.
This commit is contained in:
@@ -39,25 +39,34 @@ func TestLLMServerCompletionFormat(t *testing.T) {
|
||||
|
||||
cancel() // prevent further processing if request makes it past the format check
|
||||
|
||||
checkCanceled := func(err error) {
|
||||
checkValid := func(err error) {
|
||||
t.Helper()
|
||||
if !errors.Is(err, context.Canceled) {
|
||||
t.Fatalf("Completion: err = %v; expected context.Canceled", err)
|
||||
}
|
||||
}
|
||||
|
||||
valids := []string{`"json"`, `{"type":"object"}`, ``, `""`}
|
||||
valids := []string{
|
||||
// "missing"
|
||||
``,
|
||||
`""`,
|
||||
`null`,
|
||||
|
||||
// JSON
|
||||
`"json"`,
|
||||
`{"type":"object"}`,
|
||||
}
|
||||
for _, valid := range valids {
|
||||
err := s.Completion(ctx, CompletionRequest{
|
||||
Options: new(api.Options),
|
||||
Format: []byte(valid),
|
||||
}, nil)
|
||||
checkCanceled(err)
|
||||
checkValid(err)
|
||||
}
|
||||
|
||||
err := s.Completion(ctx, CompletionRequest{
|
||||
Options: new(api.Options),
|
||||
Format: nil, // missing format
|
||||
}, nil)
|
||||
checkCanceled(err)
|
||||
checkValid(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user