llm: consider null format same as empty value
This commit is contained in:
parent
2cde4b8817
commit
04314765f2
@ -701,7 +701,7 @@ func (s *llmServer) Completion(ctx context.Context, req CompletionRequest, fn fu
|
|||||||
|
|
||||||
if len(req.Format) > 0 {
|
if len(req.Format) > 0 {
|
||||||
switch {
|
switch {
|
||||||
case bytes.Equal(req.Format, []byte(`""`)):
|
case bytes.Equal(req.Format, []byte(`""`)) || bytes.Equal(req.Format, []byte(`null`)):
|
||||||
// fallthrough
|
// fallthrough
|
||||||
case bytes.Equal(req.Format, []byte(`"json"`)):
|
case bytes.Equal(req.Format, []byte(`"json"`)):
|
||||||
request["grammar"] = grammarJSON
|
request["grammar"] = grammarJSON
|
||||||
|
@ -46,7 +46,7 @@ func TestLLMServerCompletionFormat(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
valids := []string{`"json"`, `{"type":"object"}`, ``, `""`}
|
valids := []string{`"json"`, `{"type":"object"}`, ``, `""`, `null`}
|
||||||
for _, valid := range valids {
|
for _, valid := range valids {
|
||||||
err := s.Completion(ctx, CompletionRequest{
|
err := s.Completion(ctx, CompletionRequest{
|
||||||
Options: new(api.Options),
|
Options: new(api.Options),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user