feat(relay): expose user and group context to parameter overrides (#6534)

This commit is contained in:
Seefs
2026-08-10 12:49:06 +08:00
committed by GitHub
parent eab18a8357
commit 85feb7a345
2 changed files with 118 additions and 0 deletions
+8
View File
@@ -2094,6 +2094,10 @@ func mergeObjects(data []byte, path string, value interface{}, keepOrigin bool)
// 目前内置以下字段:
// - upstream_model/model:始终为通道映射后的上游模型名。
// - original_model:请求最初指定的模型名。
// - user_id:已认证用户 ID。
// - user_group:用户所属分组。
// - token_group:令牌指定的分组;未指定时回退为用户分组。
// - using_group:当前实际使用的分组,自动跨分组重试时可能变化。
// - request_path:请求路径
// - is_channel_test:是否为渠道测试请求(同 is_test)。
func BuildParamOverrideContext(info *RelayInfo) map[string]interface{} {
@@ -2102,6 +2106,10 @@ func BuildParamOverrideContext(info *RelayInfo) map[string]interface{} {
}
ctx := make(map[string]interface{})
ctx["user_id"] = info.UserId
ctx["user_group"] = info.UserGroup
ctx["token_group"] = info.TokenGroup
ctx["using_group"] = info.UsingGroup
if info.ChannelMeta != nil && info.ChannelMeta.UpstreamModelName != "" {
ctx["model"] = info.ChannelMeta.UpstreamModelName
ctx["upstream_model"] = info.ChannelMeta.UpstreamModelName