mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
fix(thinking): use static lookup to avoid alias issues
This commit is contained in:
@@ -54,7 +54,7 @@ func init() {
|
||||
// }
|
||||
func (a *Applier) Apply(body []byte, config thinking.ThinkingConfig, modelInfo *registry.ModelInfo) ([]byte, error) {
|
||||
if modelInfo == nil {
|
||||
return body, nil
|
||||
return applyCompatibleClaude(body, config)
|
||||
}
|
||||
if modelInfo.Thinking == nil {
|
||||
if modelInfo.Type == "" {
|
||||
|
||||
@@ -45,7 +45,7 @@ func init() {
|
||||
// }
|
||||
func (a *Applier) Apply(body []byte, config thinking.ThinkingConfig, modelInfo *registry.ModelInfo) ([]byte, error) {
|
||||
if modelInfo == nil {
|
||||
return body, nil
|
||||
return applyCompatibleCodex(body, config)
|
||||
}
|
||||
if modelInfo.Thinking == nil {
|
||||
if modelInfo.Type == "" {
|
||||
|
||||
@@ -60,7 +60,7 @@ func init() {
|
||||
// }
|
||||
func (a *Applier) Apply(body []byte, config thinking.ThinkingConfig, modelInfo *registry.ModelInfo) ([]byte, error) {
|
||||
if modelInfo == nil {
|
||||
return body, nil
|
||||
return a.applyCompatible(body, config)
|
||||
}
|
||||
if modelInfo.Thinking == nil {
|
||||
if modelInfo.Type == "" {
|
||||
|
||||
@@ -450,8 +450,9 @@ func TestGeminiApplyNilModelInfo(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Apply() with nil modelInfo should not error, got: %v", err)
|
||||
}
|
||||
if string(result) != string(body) {
|
||||
t.Fatalf("Apply() with nil modelInfo should return original body, got: %s", result)
|
||||
// nil modelInfo now applies compatible config
|
||||
if !gjson.GetBytes(result, "generationConfig.thinkingConfig.thinkingBudget").Exists() {
|
||||
t.Fatalf("Apply() with nil modelInfo should apply thinking config, got: %s", result)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func init() {
|
||||
// Apply applies thinking configuration to Gemini CLI request body.
|
||||
func (a *Applier) Apply(body []byte, config thinking.ThinkingConfig, modelInfo *registry.ModelInfo) ([]byte, error) {
|
||||
if modelInfo == nil {
|
||||
return body, nil
|
||||
return a.applyCompatible(body, config)
|
||||
}
|
||||
if modelInfo.Thinking == nil {
|
||||
if modelInfo.Type == "" {
|
||||
|
||||
@@ -241,8 +241,9 @@ func TestGeminiCLIApplyNilModelInfo(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Apply() with nil modelInfo should not error, got: %v", err)
|
||||
}
|
||||
if string(result) != string(body) {
|
||||
t.Fatalf("Apply() with nil modelInfo should return original body, got: %s", result)
|
||||
// nil modelInfo now applies compatible config
|
||||
if !gjson.GetBytes(result, "request.generationConfig.thinkingConfig.thinkingBudget").Exists() {
|
||||
t.Fatalf("Apply() with nil modelInfo should apply thinking config, got: %s", result)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,9 +278,9 @@ func TestGeminiCLIApplyModeBudgetWithLevels(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Apply() error = %v", err)
|
||||
}
|
||||
// ModeBudget with Levels model: Apply returns body unchanged (conversion is upper layer's job)
|
||||
if string(result) != string(body) {
|
||||
t.Fatalf("Apply() ModeBudget with Levels should return original body, got: %s", result)
|
||||
// ModeBudget applies budget format directly without conversion to levels
|
||||
if !gjson.GetBytes(result, "request.generationConfig.thinkingConfig.thinkingBudget").Exists() {
|
||||
t.Fatalf("Apply() ModeBudget should apply budget format, got: %s", result)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ func init() {
|
||||
// }
|
||||
func (a *Applier) Apply(body []byte, config thinking.ThinkingConfig, modelInfo *registry.ModelInfo) ([]byte, error) {
|
||||
if modelInfo == nil {
|
||||
return body, nil
|
||||
return applyCompatibleOpenAI(body, config)
|
||||
}
|
||||
if modelInfo.Thinking == nil {
|
||||
if modelInfo.Type == "" {
|
||||
|
||||
@@ -43,12 +43,14 @@ func TestApplierImplementsInterface(t *testing.T) {
|
||||
func TestApplyNilModelInfo(t *testing.T) {
|
||||
applier := NewApplier()
|
||||
body := []byte(`{"model":"gpt-5.2"}`)
|
||||
got, err := applier.Apply(body, thinking.ThinkingConfig{}, nil)
|
||||
config := thinking.ThinkingConfig{Mode: thinking.ModeLevel, Level: thinking.LevelHigh}
|
||||
got, err := applier.Apply(body, config, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("expected nil error, got %v", err)
|
||||
}
|
||||
if string(got) != string(body) {
|
||||
t.Fatalf("expected body unchanged, got %s", string(got))
|
||||
// nil modelInfo now applies compatible config
|
||||
if !gjson.GetBytes(got, "reasoning_effort").Exists() {
|
||||
t.Fatalf("expected reasoning_effort applied, got %s", string(got))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user