feat: update relay-text to conditionally include usage based on StreamOptions #696

This commit is contained in:
CaIon
2025-08-09 17:51:49 +08:00
parent 919eacd907
commit 229dd3a123

View File

@@ -140,10 +140,10 @@ func TextHelper(c *gin.Context) (newAPIError *types.NewAPIError) {
returnPreConsumedQuota(c, relayInfo, userQuota, preConsumedQuota) returnPreConsumedQuota(c, relayInfo, userQuota, preConsumedQuota)
} }
}() }()
includeUsage := false includeUsage := true
// 判断用户是否需要返回使用情况 // 判断用户是否需要返回使用情况
if textRequest.StreamOptions != nil && textRequest.StreamOptions.IncludeUsage { if textRequest.StreamOptions != nil {
includeUsage = true includeUsage = textRequest.StreamOptions.IncludeUsage
} }
// 如果不支持StreamOptions将StreamOptions设置为nil // 如果不支持StreamOptions将StreamOptions设置为nil
@@ -158,9 +158,7 @@ func TextHelper(c *gin.Context) (newAPIError *types.NewAPIError) {
} }
} }
if includeUsage { relayInfo.ShouldIncludeUsage = includeUsage
relayInfo.ShouldIncludeUsage = true
}
adaptor := GetAdaptor(relayInfo.ApiType) adaptor := GetAdaptor(relayInfo.ApiType)
if adaptor == nil { if adaptor == nil {