refactor: move functions to render package

This commit is contained in:
JustSong
2024-06-30 18:26:47 +08:00
parent 1923ded809
commit 616759933a
15 changed files with 70 additions and 51 deletions

View File

@@ -4,6 +4,7 @@ import (
"bufio"
"encoding/json"
"fmt"
"github.com/songquanpeng/one-api/common/render"
"io"
"net/http"
"strconv"
@@ -124,7 +125,7 @@ func StreamHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusC
documents = AIProxyLibraryResponse.Documents
}
response := streamResponseAIProxyLibrary2OpenAI(&AIProxyLibraryResponse)
err = common.RenderData(c, response)
err = render.ObjectData(c, response)
if err != nil {
logger.SysError(err.Error())
}
@@ -135,11 +136,11 @@ func StreamHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusC
}
response := documentsAIProxyLibrary(documents)
err := common.RenderData(c, response)
err := render.ObjectData(c, response)
if err != nil {
logger.SysError(err.Error())
}
common.RenderStringData(c, "[DONE]")
render.Done(c)
err = resp.Body.Close()
if err != nil {