feat: publish sanitized custom.97 source

This commit is contained in:
cneicy committed 2026-10-27 20:43:39 +08:00
1 parent 8e6ed0317b
commit 86c0276156
1022 files changed
+69903 -19207

No files matched your search

+13 -4
View File
@@ -7,6 +7,7 @@ import (
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/logger"
relaycommon "github.com/QuantumNous/new-api/relay/common"
"github.com/QuantumNous/new-api/relaykit/dto"
"github.com/QuantumNous/new-api/relaykit/types"
@@ -65,7 +66,7 @@ func ClaudeData(c *gin.Context, resp dto.ClaudeResponse) error {
jsonData, err := common.Marshal(resp)
if err != nil {
common.SysError("error marshalling stream response: " + err.Error())
common.SysError(common.LogText("error marshalling stream response: %s", err.Error()))
} else {
c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("event: %s\n", resp.Type)})
c.Render(-1, common.CustomEvent{Data: "data: " + string(jsonData)})
@@ -91,7 +92,15 @@ func ResponseChunkData(c *gin.Context, resp dto.ResponsesStreamResponse, data st
c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("event: %s\n", resp.Type)})
c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("data: %s", data)})
return FlushWriter(c)
err := FlushWriter(c)
if err == nil {
if value, exists := c.Get(relaycommon.UpstreamTimingContextKey); exists {
if timing, ok := value.(*relaycommon.UpstreamTiming); ok {
timing.Mark("first_downstream_flush")
}
}
}
return err
}
func StringData(c *gin.Context, str string) error {
@@ -139,7 +148,7 @@ func Done(c *gin.Context) {
func WssString(c *gin.Context, ws *websocket.Conn, str string) error {
if ws == nil {
logger.LogError(c, "websocket connection is nil")
logger.LogError(c, common.LogText("websocket connection is nil"))
return errors.New("websocket connection is nil")
}
//common.LogInfo(c, fmt.Sprintf("sending message: %s", str))
@@ -152,7 +161,7 @@ func WssObject(c *gin.Context, ws *websocket.Conn, object any) error {
return fmt.Errorf("error marshalling object: %w", err)
}
if ws == nil {
logger.LogError(c, "websocket connection is nil")
logger.LogError(c, common.LogText("websocket connection is nil"))
return errors.New("websocket connection is nil")
}
//common.LogInfo(c, fmt.Sprintf("sending message: %s", jsonData))