mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-08 17:53:41 +08:00
featL add token-side model selection
This commit is contained in:
@@ -69,6 +69,27 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
|
||||
isModelMapped = true
|
||||
}
|
||||
}
|
||||
|
||||
// Get token info
|
||||
tokenInfo, err := model.GetTokenById(tokenId)
|
||||
|
||||
if err != nil {
|
||||
return errorWrapper(err, "get_token_info_failed", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
hasModelAvailable := func() bool {
|
||||
for _, token := range strings.Split(tokenInfo.Models, ",") {
|
||||
if token == textRequest.Model {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}()
|
||||
|
||||
if !hasModelAvailable {
|
||||
return errorWrapper(errors.New("model not available for use"), "model_not_available_for_use", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
baseURL := common.ChannelBaseURLs[channelType]
|
||||
requestURL := c.Request.URL.String()
|
||||
if c.GetString("base_url") != "" {
|
||||
|
||||
Reference in New Issue
Block a user