diff --git a/constant/context_key.go b/constant/context_key.go index 2ba2fe2748..c28ad20251 100644 --- a/constant/context_key.go +++ b/constant/context_key.go @@ -65,4 +65,5 @@ const ( // ContextKeyLanguage stores the user's language preference for i18n ContextKeyLanguage ContextKey = "language" + ContextKeyIsStream ContextKey = "is_stream" ) diff --git a/controller/relay.go b/controller/relay.go index a518beed7f..a6f3f03590 100644 --- a/controller/relay.go +++ b/controller/relay.go @@ -389,7 +389,7 @@ func processChannelError(c *gin.Context, channelError types.ChannelError, err *t startTime = time.Now() } useTimeSeconds := int(time.Since(startTime).Seconds()) - model.RecordErrorLog(c, userId, channelId, modelName, tokenName, err.MaskSensitiveErrorWithStatusCode(), tokenId, useTimeSeconds, false, userGroup, other) + model.RecordErrorLog(c, userId, channelId, modelName, tokenName, err.MaskSensitiveErrorWithStatusCode(), tokenId, useTimeSeconds, common.GetContextKeyBool(c, constant.ContextKeyIsStream), userGroup, other) } } diff --git a/relay/common/relay_info.go b/relay/common/relay_info.go index 7d4f063c5a..0bb75ee618 100644 --- a/relay/common/relay_info.go +++ b/relay/common/relay_info.go @@ -438,6 +438,7 @@ func genBaseRelayInfo(c *gin.Context, request dto.Request) *RelayInfo { if request != nil { isStream = request.IsStream(c) } + c.Set(string(constant.ContextKeyIsStream), isStream) // firstResponseTime = time.Now() - 1 second