Explorar o código

fix error on accumulating final chat response

Jeffrey Morgan hai 1 ano
pai
achega
045b855db9
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      server/routes.go

+ 4 - 1
server/routes.go

@@ -1025,7 +1025,10 @@ func ChatHandler(c *gin.Context) {
 		for resp := range ch {
 			switch r := resp.(type) {
 			case api.ChatResponse:
-				sb.WriteString(r.Message.Content)
+				if r.Message != nil {
+					sb.WriteString(r.Message.Content)
+				}
+
 				final = r
 			case gin.H:
 				if errorMsg, ok := r["error"].(string); ok {