فهرست منبع

llm: consider null format same as empty value

jmorganca 4 ماه پیش
والد
کامیت
04314765f2
2فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 1 1
      llm/server.go
  2. 1 1
      llm/server_test.go

+ 1 - 1
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

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