featL add token-side model selection

This commit is contained in:
ckt1031
2023-07-14 22:41:22 +08:00
parent 4043fccedb
commit e4500bf8bf
5 changed files with 85 additions and 5 deletions

View File

@@ -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") != "" {