MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / ClaudeData

Function ClaudeData

relay/helper/common.go:32–46  ·  view source on GitHub ↗
(c *gin.Context, resp dto.ClaudeResponse)

Source from the content-addressed store, hash-verified

30}
31
32func ClaudeData(c *gin.Context, resp dto.ClaudeResponse) error {
33 jsonData, err := json.Marshal(resp)
34 if err != nil {
35 common.SysError("error marshalling stream response: " + err.Error())
36 } else {
37 c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("event: %s\n", resp.Type)})
38 c.Render(-1, common.CustomEvent{Data: "data: " + string(jsonData)})
39 }
40 if flusher, ok := c.Writer.(http.Flusher); ok {
41 flusher.Flush()
42 } else {
43 return errors.New("streaming error: flusher not found")
44 }
45 return nil
46}
47
48func ClaudeChunkData(c *gin.Context, resp dto.ClaudeResponse, data string) {
49 c.Render(-1, common.CustomEvent{Data: fmt.Sprintf("event: %s\n", resp.Type)})

Callers 2

handleClaudeFormatFunction · 0.92
handleFinalResponseFunction · 0.92

Calls 3

SysErrorFunction · 0.92
ErrorMethod · 0.80
RenderMethod · 0.80

Tested by

no test coverage detected