mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-06-02 21:13:44 +08:00
feat(codex): pass base model to enable conditional image_generation tool injection
- Modified `ensureImageGenerationTool` to accept `baseModel` for conditional logic. - Ensured `gpt-5.3-codex-spark` models bypass image_generation tool injection. - Updated relevant tests and executor logic to reflect changes.
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
func TestEnsureImageGenerationTool_NoTools(t *testing.T) {
|
||||
body := []byte(`{"model":"gpt-5.4","input":"draw a cat"}`)
|
||||
result := ensureImageGenerationTool(body)
|
||||
result := ensureImageGenerationTool(body, "gpt-5.4")
|
||||
|
||||
tools := gjson.GetBytes(result, "tools")
|
||||
if !tools.IsArray() {
|
||||
@@ -28,7 +28,7 @@ func TestEnsureImageGenerationTool_NoTools(t *testing.T) {
|
||||
|
||||
func TestEnsureImageGenerationTool_ExistingToolsWithoutImageGen(t *testing.T) {
|
||||
body := []byte(`{"model":"gpt-5.4","tools":[{"type":"function","name":"get_weather","parameters":{}}]}`)
|
||||
result := ensureImageGenerationTool(body)
|
||||
result := ensureImageGenerationTool(body, "gpt-5.4")
|
||||
|
||||
tools := gjson.GetBytes(result, "tools")
|
||||
arr := tools.Array()
|
||||
@@ -45,7 +45,7 @@ func TestEnsureImageGenerationTool_ExistingToolsWithoutImageGen(t *testing.T) {
|
||||
|
||||
func TestEnsureImageGenerationTool_AlreadyPresent(t *testing.T) {
|
||||
body := []byte(`{"model":"gpt-5.4","tools":[{"type":"image_generation","output_format":"webp"},{"type":"function","name":"f1"}]}`)
|
||||
result := ensureImageGenerationTool(body)
|
||||
result := ensureImageGenerationTool(body, "gpt-5.4")
|
||||
|
||||
tools := gjson.GetBytes(result, "tools")
|
||||
arr := tools.Array()
|
||||
@@ -59,7 +59,7 @@ func TestEnsureImageGenerationTool_AlreadyPresent(t *testing.T) {
|
||||
|
||||
func TestEnsureImageGenerationTool_EmptyToolsArray(t *testing.T) {
|
||||
body := []byte(`{"model":"gpt-5.4","tools":[]}`)
|
||||
result := ensureImageGenerationTool(body)
|
||||
result := ensureImageGenerationTool(body, "gpt-5.4")
|
||||
|
||||
tools := gjson.GetBytes(result, "tools")
|
||||
arr := tools.Array()
|
||||
@@ -73,7 +73,7 @@ func TestEnsureImageGenerationTool_EmptyToolsArray(t *testing.T) {
|
||||
|
||||
func TestEnsureImageGenerationTool_WebSearchAndImageGen(t *testing.T) {
|
||||
body := []byte(`{"model":"gpt-5.4","tools":[{"type":"web_search"}]}`)
|
||||
result := ensureImageGenerationTool(body)
|
||||
result := ensureImageGenerationTool(body, "gpt-5.4")
|
||||
|
||||
tools := gjson.GetBytes(result, "tools")
|
||||
arr := tools.Array()
|
||||
@@ -87,3 +87,15 @@ func TestEnsureImageGenerationTool_WebSearchAndImageGen(t *testing.T) {
|
||||
t.Fatalf("expected second tool type=image_generation, got %s", arr[1].Get("type").String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnsureImageGenerationTool_GPT53CodexSparkDoesNotInjectTool(t *testing.T) {
|
||||
body := []byte(`{"model":"gpt-5.3-codex-spark","input":"draw a cat"}`)
|
||||
result := ensureImageGenerationTool(body, "gpt-5.3-codex-spark")
|
||||
|
||||
if string(result) != string(body) {
|
||||
t.Fatalf("expected body to be unchanged, got %s", string(result))
|
||||
}
|
||||
if gjson.GetBytes(result, "tools").Exists() {
|
||||
t.Fatalf("expected no tools for gpt-5.3-codex-spark, got %s", gjson.GetBytes(result, "tools").Raw)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user