mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 04:10:51 +08:00
49 lines
1.7 KiB
Go
49 lines
1.7 KiB
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/translator"
|
|
|
|
sdktranslator "github.com/router-for-me/CLIProxyAPI/v6/sdk/translator"
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
func TestOpenAIToCodex_PreservesBuiltinTools(t *testing.T) {
|
|
in := []byte(`{
|
|
"model":"gpt-5",
|
|
"messages":[{"role":"user","content":"hi"}],
|
|
"tools":[{"type":"web_search","search_context_size":"high"}],
|
|
"tool_choice":{"type":"web_search"}
|
|
}`)
|
|
|
|
out := sdktranslator.TranslateRequest(sdktranslator.FormatOpenAI, sdktranslator.FormatCodex, "gpt-5", in, false)
|
|
|
|
if got := gjson.GetBytes(out, "tools.#").Int(); got != 1 {
|
|
t.Fatalf("expected 1 tool, got %d: %s", got, string(out))
|
|
}
|
|
if got := gjson.GetBytes(out, "tools.0.type").String(); got != "web_search" {
|
|
t.Fatalf("expected tools[0].type=web_search, got %q: %s", got, string(out))
|
|
}
|
|
if got := gjson.GetBytes(out, "tools.0.search_context_size").String(); got != "high" {
|
|
t.Fatalf("expected tools[0].search_context_size=high, got %q: %s", got, string(out))
|
|
}
|
|
if got := gjson.GetBytes(out, "tool_choice.type").String(); got != "web_search" {
|
|
t.Fatalf("expected tool_choice.type=web_search, got %q: %s", got, string(out))
|
|
}
|
|
}
|
|
|
|
func TestOpenAIResponsesToOpenAI_IgnoresBuiltinTools(t *testing.T) {
|
|
in := []byte(`{
|
|
"model":"gpt-5",
|
|
"input":[{"role":"user","content":[{"type":"input_text","text":"hi"}]}],
|
|
"tools":[{"type":"web_search","search_context_size":"low"}]
|
|
}`)
|
|
|
|
out := sdktranslator.TranslateRequest(sdktranslator.FormatOpenAIResponse, sdktranslator.FormatOpenAI, "gpt-5", in, false)
|
|
|
|
if got := gjson.GetBytes(out, "tools.#").Int(); got != 0 {
|
|
t.Fatalf("expected 0 tools (builtin tools not supported in Chat Completions), got %d: %s", got, string(out))
|
|
}
|
|
}
|