mirror of
https://github.com/githubhjs/CLIProxyAPIPlus.git
synced 2026-07-12 01:25:13 +00:00
Merge branch 'router-for-me:main' into main
This commit is contained in:
@@ -71,7 +71,7 @@ type Config struct {
|
|||||||
// WebsocketAuth enables or disables authentication for the WebSocket API.
|
// WebsocketAuth enables or disables authentication for the WebSocket API.
|
||||||
WebsocketAuth bool `yaml:"ws-auth" json:"ws-auth"`
|
WebsocketAuth bool `yaml:"ws-auth" json:"ws-auth"`
|
||||||
|
|
||||||
// CodexInstructionsEnabled controls whether custom Codex instructions are injected.
|
// CodexInstructionsEnabled controls whether official Codex instructions are injected.
|
||||||
// When false (default), CodexInstructionsForModel returns immediately without modification.
|
// When false (default), CodexInstructionsForModel returns immediately without modification.
|
||||||
// When true, the original instruction injection logic is used.
|
// When true, the original instruction injection logic is used.
|
||||||
CodexInstructionsEnabled bool `yaml:"codex-instructions-enabled" json:"codex-instructions-enabled"`
|
CodexInstructionsEnabled bool `yaml:"codex-instructions-enabled" json:"codex-instructions-enabled"`
|
||||||
|
|||||||
@@ -122,6 +122,23 @@ func migrateFromOldField(configFile string, root *yaml.Node, rootMap *yaml.Node,
|
|||||||
newAliases[channel] = converted
|
newAliases[channel] = converted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For antigravity channel, supplement missing default aliases
|
||||||
|
if antigravityEntries, exists := newAliases["antigravity"]; exists {
|
||||||
|
// Build a set of already configured model names (upstream names)
|
||||||
|
configuredModels := make(map[string]bool, len(antigravityEntries))
|
||||||
|
for _, entry := range antigravityEntries {
|
||||||
|
configuredModels[entry.Name] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add missing default aliases
|
||||||
|
for _, defaultAlias := range defaultAntigravityAliases() {
|
||||||
|
if !configuredModels[defaultAlias.Name] {
|
||||||
|
antigravityEntries = append(antigravityEntries, defaultAlias)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newAliases["antigravity"] = antigravityEntries
|
||||||
|
}
|
||||||
|
|
||||||
// Build new node
|
// Build new node
|
||||||
newNode := buildOAuthModelAliasNode(newAliases)
|
newNode := buildOAuthModelAliasNode(newAliases)
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,23 @@ func TestMigrateOAuthModelAlias_ConvertsAntigravityModels(t *testing.T) {
|
|||||||
if !strings.Contains(content, "gemini-3-pro-high") {
|
if !strings.Contains(content, "gemini-3-pro-high") {
|
||||||
t.Fatal("expected gemini-3-pro-preview to be converted to gemini-3-pro-high")
|
t.Fatal("expected gemini-3-pro-preview to be converted to gemini-3-pro-high")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify missing default aliases were supplemented
|
||||||
|
if !strings.Contains(content, "gemini-3-pro-image") {
|
||||||
|
t.Fatal("expected missing default alias gemini-3-pro-image to be added")
|
||||||
|
}
|
||||||
|
if !strings.Contains(content, "gemini-3-flash") {
|
||||||
|
t.Fatal("expected missing default alias gemini-3-flash to be added")
|
||||||
|
}
|
||||||
|
if !strings.Contains(content, "claude-sonnet-4-5") {
|
||||||
|
t.Fatal("expected missing default alias claude-sonnet-4-5 to be added")
|
||||||
|
}
|
||||||
|
if !strings.Contains(content, "claude-sonnet-4-5-thinking") {
|
||||||
|
t.Fatal("expected missing default alias claude-sonnet-4-5-thinking to be added")
|
||||||
|
}
|
||||||
|
if !strings.Contains(content, "claude-opus-4-5-thinking") {
|
||||||
|
t.Fatal("expected missing default alias claude-opus-4-5-thinking to be added")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMigrateOAuthModelAlias_AddsDefaultIfNeitherExists(t *testing.T) {
|
func TestMigrateOAuthModelAlias_AddsDefaultIfNeitherExists(t *testing.T) {
|
||||||
|
|||||||
@@ -1221,7 +1221,7 @@ func (e *AntigravityExecutor) buildRequest(ctx context.Context, auth *cliproxyau
|
|||||||
payload = []byte(strJSON)
|
payload = []byte(strJSON)
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(modelName, "claude") || strings.Contains(modelName, "gemini-3-pro-preview") {
|
if strings.Contains(modelName, "claude") || strings.Contains(modelName, "gemini-3-pro-high") {
|
||||||
systemInstructionPartsResult := gjson.GetBytes(payload, "request.systemInstruction.parts")
|
systemInstructionPartsResult := gjson.GetBytes(payload, "request.systemInstruction.parts")
|
||||||
payload, _ = sjson.SetBytes(payload, "request.systemInstruction.role", "user")
|
payload, _ = sjson.SetBytes(payload, "request.systemInstruction.role", "user")
|
||||||
payload, _ = sjson.SetBytes(payload, "request.systemInstruction.parts.0.text", systemInstruction)
|
payload, _ = sjson.SetBytes(payload, "request.systemInstruction.parts.0.text", systemInstruction)
|
||||||
|
|||||||
@@ -106,6 +106,9 @@ func (e *CodexExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, re
|
|||||||
body, _ = sjson.SetBytes(body, "stream", true)
|
body, _ = sjson.SetBytes(body, "stream", true)
|
||||||
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
||||||
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
||||||
|
if !gjson.GetBytes(body, "instructions").Exists() {
|
||||||
|
body, _ = sjson.SetBytes(body, "instructions", "")
|
||||||
|
}
|
||||||
|
|
||||||
url := strings.TrimSuffix(baseURL, "/") + "/responses"
|
url := strings.TrimSuffix(baseURL, "/") + "/responses"
|
||||||
httpReq, err := e.cacheHelper(ctx, from, url, req, body)
|
httpReq, err := e.cacheHelper(ctx, from, url, req, body)
|
||||||
@@ -213,6 +216,9 @@ func (e *CodexExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Au
|
|||||||
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
||||||
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
||||||
body, _ = sjson.SetBytes(body, "model", baseModel)
|
body, _ = sjson.SetBytes(body, "model", baseModel)
|
||||||
|
if !gjson.GetBytes(body, "instructions").Exists() {
|
||||||
|
body, _ = sjson.SetBytes(body, "instructions", "")
|
||||||
|
}
|
||||||
|
|
||||||
url := strings.TrimSuffix(baseURL, "/") + "/responses"
|
url := strings.TrimSuffix(baseURL, "/") + "/responses"
|
||||||
httpReq, err := e.cacheHelper(ctx, from, url, req, body)
|
httpReq, err := e.cacheHelper(ctx, from, url, req, body)
|
||||||
@@ -317,6 +323,9 @@ func (e *CodexExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth
|
|||||||
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
body, _ = sjson.DeleteBytes(body, "previous_response_id")
|
||||||
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
body, _ = sjson.DeleteBytes(body, "prompt_cache_retention")
|
||||||
body, _ = sjson.SetBytes(body, "stream", false)
|
body, _ = sjson.SetBytes(body, "stream", false)
|
||||||
|
if !gjson.GetBytes(body, "instructions").Exists() {
|
||||||
|
body, _ = sjson.SetBytes(body, "instructions", "")
|
||||||
|
}
|
||||||
|
|
||||||
enc, err := tokenizerForCodexModel(baseModel)
|
enc, err := tokenizerForCodexModel(baseModel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user