feat(adaptor): refactor response handlers to return usage first and improve error handling

This commit is contained in:
CaIon
2025-07-12 21:12:46 +08:00
parent 20607b0b5c
commit 52a5e58f0c
5 changed files with 28 additions and 28 deletions

View File

@@ -74,12 +74,12 @@ func (a *Adaptor) ConvertEmbeddingRequest(c *gin.Context, info *relaycommon.Rela
func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (usage any, err *types.NewAPIError) {
if info.RelayMode == constant.RelayModeRerank {
err, usage = cohereRerankHandler(c, resp, info)
usage, err = cohereRerankHandler(c, resp, info)
} else {
if info.IsStream {
err, usage = cohereStreamHandler(c, info, resp)
usage, err = cohereStreamHandler(c, info, resp) // TODO: fix this
} else {
err, usage = cohereHandler(c, info, resp)
usage, err = cohereHandler(c, info, resp)
}
}
return