fix: provide a default value for api-version if not given (#57)

This commit is contained in:
JustSong 2023-05-13 11:41:57 +08:00
parent 7a3378b4b7
commit 44729da277

View File

@ -93,6 +93,10 @@ func relayHelper(c *gin.Context) error {
fullRequestURL := fmt.Sprintf("%s%s", baseURL, requestURL)
if channelType == common.ChannelTypeAzure {
// https://learn.microsoft.com/en-us/azure/cognitive-services/openai/chatgpt-quickstart?pivots=rest-api&tabs=command-line#rest-api
query := c.Request.URL.Query()
if query.Get("api-version") == "" {
requestURL = fmt.Sprintf("%s?api-version=2023-03-15-preview", requestURL)
}
baseURL = c.GetString("base_url")
task := strings.TrimPrefix(requestURL, "/v1/")
model_ := textRequest.Model