mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
Merge pull request #2412 from gaoren002/fix/codex-auto-review-gpt55
fix(openai): add codex auto review model pricing
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
var codexModelMap = map[string]string{
|
||||
"gpt-5.5": "gpt-5.5",
|
||||
"codex-auto-review": "codex-auto-review",
|
||||
"gpt-5.4": "gpt-5.4",
|
||||
"gpt-5.4-mini": "gpt-5.4-mini",
|
||||
"gpt-5.4-none": "gpt-5.4",
|
||||
|
||||
@@ -839,6 +839,7 @@ func TestNormalizeCodexModel_Gpt53(t *testing.T) {
|
||||
"gpt-5.4": "gpt-5.4",
|
||||
"gpt5.5": "gpt-5.5",
|
||||
"openai/gpt5.5": "gpt-5.5",
|
||||
"codex-auto-review": "codex-auto-review",
|
||||
"gpt5.4": "gpt-5.4",
|
||||
"gpt-5.4-high": "gpt-5.4",
|
||||
"gpt-5.4-chat-latest": "gpt-5.4",
|
||||
|
||||
@@ -261,6 +261,12 @@ func TestNormalizeOpenAIModelForUpstream(t *testing.T) {
|
||||
model: "gpt-5.4-high",
|
||||
want: "gpt-5.4",
|
||||
},
|
||||
{
|
||||
name: "oauth preserves codex auto review model",
|
||||
account: &Account{Type: AccountTypeOAuth},
|
||||
model: "codex-auto-review",
|
||||
want: "codex-auto-review",
|
||||
},
|
||||
{
|
||||
name: "apikey preserves custom compatible model",
|
||||
account: &Account{Type: AccountTypeAPIKey},
|
||||
@@ -283,3 +289,17 @@ func TestNormalizeOpenAIModelForUpstream(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUsageBillingModelCandidatesPreserveCodexAutoReviewModel(t *testing.T) {
|
||||
candidates := usageBillingModelCandidates("codex-auto-review")
|
||||
|
||||
expected := []string{"codex-auto-review"}
|
||||
if len(candidates) != len(expected) {
|
||||
t.Fatalf("usageBillingModelCandidates(codex-auto-review) = %#v, want %#v", candidates, expected)
|
||||
}
|
||||
for i := range expected {
|
||||
if candidates[i] != expected[i] {
|
||||
t.Fatalf("usageBillingModelCandidates(codex-auto-review) = %#v, want %#v", candidates, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -111,6 +113,22 @@ func TestGetModelPricing_OpenAICompactAliasUsesStaticFallback(t *testing.T) {
|
||||
require.InDelta(t, 1.5e-5, got.OutputCostPerToken, 1e-12)
|
||||
}
|
||||
|
||||
func TestDefaultPricingIncludesCodexAutoReview(t *testing.T) {
|
||||
data, err := os.ReadFile(filepath.Join("..", "..", "resources", "model-pricing", "model_prices_and_context_window.json"))
|
||||
require.NoError(t, err)
|
||||
|
||||
svc := &PricingService{}
|
||||
pricingData, err := svc.parsePricingData(data)
|
||||
require.NoError(t, err)
|
||||
svc.pricingData = pricingData
|
||||
|
||||
got := svc.GetModelPricing("codex-auto-review")
|
||||
require.NotNil(t, got)
|
||||
require.InDelta(t, 2.5e-6, got.InputCostPerToken, 1e-12)
|
||||
require.InDelta(t, 1.5e-5, got.OutputCostPerToken, 1e-12)
|
||||
require.InDelta(t, 2.5e-7, got.CacheReadInputTokenCost, 1e-12)
|
||||
}
|
||||
|
||||
func TestGetModelPricing_Gpt54MiniUsesDedicatedStaticFallbackWhenRemoteMissing(t *testing.T) {
|
||||
svc := &PricingService{
|
||||
pricingData: map[string]*LiteLLMModelPricing{
|
||||
|
||||
Reference in New Issue
Block a user