mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-14 00:01:53 +00:00
feat(relay): expose user and group context to parameter overrides (#6534)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user