Skip to content

Commit

Permalink
chore: mv event to render
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Feb 24, 2025
1 parent 1446064 commit 9972c35
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package common
package render

import (
"net/http"

"github.com/labring/sealos/service/aiproxy/common/conv"
)

// Server-Sent Events
// W3C Working Draft 29 October 2009
// http://www.w3.org/TR/2009/WD-eventsource-20091029/

var (
contentType = []string{"text/event-stream"}
noCache = []string{"no-cache"}
Expand Down
5 changes: 2 additions & 3 deletions service/aiproxy/common/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/gin-gonic/gin"
json "github.com/json-iterator/go"
"github.com/labring/sealos/service/aiproxy/common"
"github.com/labring/sealos/service/aiproxy/common/conv"
)

Expand All @@ -19,7 +18,7 @@ func StringData(c *gin.Context, str string) {
if c.IsAborted() {
return
}
c.Render(-1, common.OpenAISSE{Data: str})
c.Render(-1, OpenAISSE{Data: str})
c.Writer.Flush()
}

Expand All @@ -34,7 +33,7 @@ func ObjectData(c *gin.Context, object any) error {
if err != nil {
return fmt.Errorf("error marshalling object: %w", err)
}
c.Render(-1, common.OpenAISSE{Data: conv.BytesToString(jsonData)})
c.Render(-1, OpenAISSE{Data: conv.BytesToString(jsonData)})
c.Writer.Flush()
return nil
}
Expand Down

0 comments on commit 9972c35

Please sign in to comment.