mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 07:37:23 +00:00
feat: default enable channel affinity
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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' }],
|
||||
|
||||
Reference in New Issue
Block a user