feat: sync deployed v1.0.0-rc.38-custom.42

Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
This commit is contained in:
cneicy committed 2026-09-26 04:49:11 +08:00
1 parent aa6c3f50f4
commit ceddfd3d6b
828 files changed
+122253 -13702

No files matched your search

+51 -1
View File
@@ -72,6 +72,7 @@ func AppendRelayLogAdminInfo(ctx *gin.Context, relayInfo *relaycommon.RelayInfo,
return
}
other.SetAdmin("use_channel", ctx.GetStringSlice("use_channel"))
appendRequestDetails(ctx, relayInfo, other)
if relayInfo != nil {
if billingModel := relayInfo.GetBillingModelName(); billingModel != "" && billingModel != relayInfo.OriginModelName {
other.SetAdmin("billing_model", billingModel)
@@ -92,10 +93,14 @@ func AppendRelayLogAdminInfo(ctx *gin.Context, relayInfo *relaycommon.RelayInfo,
}
AppendChannelAffinityAdminInfo(ctx, other)
if events := RequestPolicy(ctx).Events(); len(events) > 0 {
other.SetAdmin("request_policy", events)
}
}
func GenerateTextOtherInfo(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, modelRatio, groupRatio, completionRatio float64,
cacheTokens int, cacheRatio float64, modelPrice float64, userGroupRatio float64) *model.LogOther {
if !ctx.GetBool("attempt_checkpoint") && ctx.GetString("attempt_guard_result") == "" { MarkRequestPolicySuccess(ctx, relayInfo.StreamStatus) }
other := model.NewLogOther()
other.SetPublic("model_ratio", modelRatio)
other.SetPublic("group_ratio", groupRatio)
@@ -119,6 +124,7 @@ func GenerateTextOtherInfo(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, m
}
AppendRelayLogAdminInfo(ctx, relayInfo, other)
AppendResponseModelLogInfo(relayInfo, other)
appendRequestPath(ctx, relayInfo, other)
appendRequestConversionChain(relayInfo, other)
appendFinalRequestFormat(relayInfo, other)
@@ -128,6 +134,20 @@ func GenerateTextOtherInfo(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, m
return other
}
func AppendResponseModelLogInfo(relayInfo *relaycommon.RelayInfo, other *model.LogOther) {
if relayInfo == nil || relayInfo.ResponseModel == nil || other == nil {
return
}
observation := relayInfo.ResponseModel
if !observation.Mismatch &&
observation.ReturnedModel == observation.RequestedModel &&
(observation.UpstreamModel == "" || observation.UpstreamModel == observation.RequestedModel) &&
(relayInfo.ChannelMeta == nil || !relayInfo.IsModelMapped) {
return
}
other.SetPublic("response_model", *observation)
}
func appendParamOverrideInfo(relayInfo *relaycommon.RelayInfo, other *model.LogOther) {
if relayInfo == nil || other == nil || len(relayInfo.ParamOverrideAudit) == 0 {
return
@@ -141,13 +161,16 @@ func appendStreamStatus(relayInfo *relaycommon.RelayInfo, other *model.LogOther)
}
ss := relayInfo.StreamStatus
status := "ok"
if ss.HasErrors() || (ss.EndReason != relaycommon.StreamEndReasonClientGone && !ss.IsNormalEnd()) {
if ss.HasErrors() || ss.ResponseFailed() || (ss.EndReason != relaycommon.StreamEndReasonClientGone && !ss.IsNormalEnd()) {
status = "error"
}
streamInfo := map[string]any{
"status": status,
"end_reason": string(ss.EndReason),
}
if outcome := ss.ResponseOutcome(); outcome != "" {
streamInfo["response_status"] = outcome
}
if ss.EndError != nil {
streamInfo["end_error"] = ss.EndError.Error()
}
@@ -322,9 +345,36 @@ func InjectTieredBillingInfo(other *model.LogOther, relayInfo *relaycommon.Relay
other.SetPublic("billing_mode", "tiered_expr")
other.SetPublic("expr_b64", base64.StdEncoding.EncodeToString([]byte(snap.ExprString)))
if result != nil {
if tokens := result.BillingTokens; tokens != nil && result.BillingUnit == billingexpr.BillingUnitToken {
other.SetPublic("image_cache_tokens", tokens.ImgCR)
other.SetPublic("billing_tokens", map[string]float64{
"p": tokens.P, "c": tokens.C, "len": tokens.Len,
"cr": tokens.CR, "cc": tokens.CC, "cc1h": tokens.CC1h,
"img": tokens.Img, "img_cr": tokens.ImgCR, "img_o": tokens.ImgO,
"ai": tokens.AI, "ao": tokens.AO,
})
}
if result.ImageCount != nil {
other.SetPublic("image_count", *result.ImageCount)
}
other.SetPublic("matched_tier", result.MatchedTier)
if result.BillingUnit != "" {
other.SetPublic("billing_unit", result.BillingUnit)
}
if result.FixedPrice != nil {
other.SetPublic("fixed_price", *result.FixedPrice)
}
if len(result.RequestRules) > 0 {
other.SetPublic("request_rules", result.RequestRules)
}
} else if snap.EstimatedBillingUnit != "" {
if snap.EstimatedImageCount != nil {
other.SetPublic("image_count", *snap.EstimatedImageCount)
}
other.SetPublic("matched_tier", snap.EstimatedTier)
other.SetPublic("billing_unit", snap.EstimatedBillingUnit)
if snap.EstimatedFixedPrice != nil {
other.SetPublic("fixed_price", *snap.EstimatedFixedPrice)
}
}
}