| 35 | } |
| 36 | |
| 37 | func writeChatCompletionStreamDone(c *gin.Context, stopSent bool, model string, conversationID string) { |
| 38 | if !stopSent { |
| 39 | finalLine := officialtypes.StopChunkWithConversation("stop", model, conversationID) |
| 40 | c.Writer.WriteString("data: " + finalLine.String() + "\n\n") |
| 41 | c.Writer.Flush() |
| 42 | } |
| 43 | c.Writer.WriteString("data: [DONE]\n\n") |
| 44 | c.Writer.Flush() |
| 45 | } |
| 46 | |
| 47 | func NewHandle(proxy *proxys.IProxy, token *tokens.AccessToken) *Handler { |
| 48 | return &Handler{proxy: proxy, token: token, sessions: NewSessionManager()} |