Selaa lähdekoodia

feat: support azure stream_options

CalciumIon 1 vuosi sitten
vanhempi
commit
62ae46b552
3 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 1 1
      relay/channel/openai/adaptor.go
  2. 1 1
      relay/common/relay_info.go
  3. 2 2
      service/token_counter.go

+ 1 - 1
relay/channel/openai/adaptor.go

@@ -106,7 +106,7 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, info *relaycommon.RelayInfo, re
 	if request == nil {
 	if request == nil {
 		return nil, errors.New("request is nil")
 		return nil, errors.New("request is nil")
 	}
 	}
-	if info.ChannelType != common.ChannelTypeOpenAI {
+	if info.ChannelType != common.ChannelTypeOpenAI && info.ChannelType != common.ChannelTypeAzure {
 		request.StreamOptions = nil
 		request.StreamOptions = nil
 	}
 	}
 	if strings.HasPrefix(request.Model, "o1") {
 	if strings.HasPrefix(request.Model, "o1") {

+ 1 - 1
relay/common/relay_info.go

@@ -109,7 +109,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
 	}
 	}
 	if info.ChannelType == common.ChannelTypeOpenAI || info.ChannelType == common.ChannelTypeAnthropic ||
 	if info.ChannelType == common.ChannelTypeOpenAI || info.ChannelType == common.ChannelTypeAnthropic ||
 		info.ChannelType == common.ChannelTypeAws || info.ChannelType == common.ChannelTypeGemini ||
 		info.ChannelType == common.ChannelTypeAws || info.ChannelType == common.ChannelTypeGemini ||
-		info.ChannelType == common.ChannelCloudflare {
+		info.ChannelType == common.ChannelCloudflare || info.ChannelType == common.ChannelTypeAzure {
 		info.SupportStreamOptions = true
 		info.SupportStreamOptions = true
 	}
 	}
 	return info
 	return info

+ 2 - 2
service/token_counter.go

@@ -92,11 +92,11 @@ func getImageToken(imageUrl *dto.MessageImageUrl, model string, stream bool) (in
 	}
 	}
 	// TODO: 非流模式下不计算图片token数量
 	// TODO: 非流模式下不计算图片token数量
 	if !constant.GetMediaTokenNotStream && !stream {
 	if !constant.GetMediaTokenNotStream && !stream {
-		return 1000, nil
+		return 256, nil
 	}
 	}
 	// 是否统计图片token
 	// 是否统计图片token
 	if !constant.GetMediaToken {
 	if !constant.GetMediaToken {
-		return 1000, nil
+		return 256, nil
 	}
 	}
 	// 同步One API的图片计费逻辑
 	// 同步One API的图片计费逻辑
 	if imageUrl.Detail == "auto" || imageUrl.Detail == "" {
 	if imageUrl.Detail == "auto" || imageUrl.Detail == "" {