feat: default enable channel affinity (#2809)

This commit is contained in:
Calcium-Ion
2026-02-03 00:05:23 +08:00
committed by GitHub
2 changed files with 33 additions and 4 deletions

View File

@@ -33,11 +33,40 @@ type ChannelAffinitySetting struct {
}
var channelAffinitySetting = ChannelAffinitySetting{
Enabled: false,
Enabled: true,
SwitchOnSuccess: true,
MaxEntries: 100_000,
DefaultTTLSeconds: 3600,
Rules: []ChannelAffinityRule{},
Rules: []ChannelAffinityRule{
{
Name: "codex trace",
ModelRegex: []string{"^gpt-.*$"},
PathRegex: []string{"/v1/responses"},
KeySources: []ChannelAffinityKeySource{
{Type: "gjson", Path: "prompt_cache_key"},
},
ValueRegex: "",
TTLSeconds: 0,
SkipRetryOnFailure: false,
IncludeUsingGroup: true,
IncludeRuleName: true,
UserAgentInclude: nil,
},
{
Name: "claude code trace",
ModelRegex: []string{"^claude-.*$"},
PathRegex: []string{"/v1/messages"},
KeySources: []ChannelAffinityKeySource{
{Type: "gjson", Path: "metadata.user_id"},
},
ValueRegex: "",
TTLSeconds: 0,
SkipRetryOnFailure: false,
IncludeUsingGroup: true,
IncludeRuleName: true,
UserAgentInclude: nil,
},
},
}
func init() {

View File

@@ -67,7 +67,7 @@ const KEY_SOURCE_TYPES = [
const RULE_TEMPLATES = {
codex: {
name: 'codex优选',
name: 'codex trace',
model_regex: ['^gpt-.*$'],
path_regex: ['/v1/responses'],
key_sources: [{ type: 'gjson', path: 'prompt_cache_key' }],
@@ -78,7 +78,7 @@ const RULE_TEMPLATES = {
include_rule_name: true,
},
claudeCode: {
name: 'claude-code优选',
name: 'claude-code trace',
model_regex: ['^claude-.*$'],
path_regex: ['/v1/messages'],
key_sources: [{ type: 'gjson', path: 'metadata.user_id' }],