feat: support DeepL's model (close #1126)

This commit is contained in:
JustSong
2024-04-27 13:37:22 +08:00
parent e64e7707a0
commit 007906216d
20 changed files with 305 additions and 10 deletions

View File

@@ -18,6 +18,7 @@ import (
"github.com/songquanpeng/one-api/relay/relaymode"
"math"
"net/http"
"strings"
)
func getAndValidateTextRequest(c *gin.Context, relayMode int) (*relaymodel.GeneralOpenAIRequest, error) {
@@ -204,3 +205,20 @@ func getMappedModelName(modelName string, mapping map[string]string) (string, bo
}
return modelName, false
}
func isErrorHappened(meta *meta.Meta, resp *http.Response) bool {
if resp == nil {
return true
}
if resp.StatusCode != http.StatusOK {
return true
}
if meta.ChannelType == channeltype.DeepL {
// skip stream check for deepl
return false
}
if meta.IsStream && strings.HasPrefix(resp.Header.Get("Content-Type"), "application/json") {
return true
}
return false
}