Просмотр исходного кода

fix: update ResponseChunkData to format data correctly without newline

CaIon 10 месяцев назад
Родитель
Сommit
dc3b453b05
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      relay/helper/common.go

+ 2 - 2
relay/helper/common.go

@@ -37,7 +37,7 @@ func ClaudeData(c *gin.Context, resp dto.ClaudeResponse) error {
 
 
 func ClaudeChunkData(c *gin.Context, resp dto.ClaudeResponse, data string) {
 func ClaudeChunkData(c *gin.Context, resp dto.ClaudeResponse, data string) {
 	c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("event: %s\n", resp.Type)})
 	c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("event: %s\n", resp.Type)})
-	c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("data: %s", data)})
+	c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("data: %s\n", data)})
 	if flusher, ok := c.Writer.(http.Flusher); ok {
 	if flusher, ok := c.Writer.(http.Flusher); ok {
 		flusher.Flush()
 		flusher.Flush()
 	}
 	}
@@ -45,7 +45,7 @@ func ClaudeChunkData(c *gin.Context, resp dto.ClaudeResponse, data string) {
 
 
 func ResponseChunkData(c *gin.Context, resp dto.ResponsesStreamResponse, data string) {
 func ResponseChunkData(c *gin.Context, resp dto.ResponsesStreamResponse, data string) {
 	c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("event: %s\n", resp.Type)})
 	c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("event: %s\n", resp.Type)})
-	c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("data: %s\n", data)})
+	c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("data: %s", data)})
 	if flusher, ok := c.Writer.(http.Flusher); ok {
 	if flusher, ok := c.Writer.(http.Flusher); ok {
 		flusher.Flush()
 		flusher.Flush()
 	}
 	}