Repository navigation
alpha search #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alpha search #30
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c0ee2ad
alpha search
CSCITech 41aadc7
alpha search
CSCITech f1b5fb0
alpha search
CSCITech 9b8e086
alpha search
CSCITech 4ed6355
alpha search
CSCITech 69e489c
alpha search
CSCITech b6b491e
alpha search
CSCITech 09654cc
alpha search
CSCITech 2d89c82
fix bugs
CSCITech bb40ae8
fix bugs
CSCITech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package common | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/MAX-API-Next/MAX-API/constant" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestCodexEndpointTypesIncludeAlphaSearch(t *testing.T) { | ||
| endpointTypes := GetEndpointTypesByChannelType(constant.ChannelTypeCodex, "gpt-5.1") | ||
|
|
||
| require.Contains(t, endpointTypes, constant.EndpointTypeOpenAIResponse) | ||
| require.Contains(t, endpointTypes, constant.EndpointTypeOpenAIResponseCompact) | ||
| require.Contains(t, endpointTypes, constant.EndpointTypeOpenAIAlphaSearch) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| package controller | ||
|
|
||
| import ( | ||
| "math" | ||
| "testing" | ||
|
|
||
| "github.com/MAX-API-Next/MAX-API/common" | ||
| "github.com/MAX-API-Next/MAX-API/setting/operation_setting" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestBillingQuotaDisplayAmountRejectsInvalidQuotaPerUnit(t *testing.T) { | ||
| oldQuotaPerUnit := common.QuotaPerUnit | ||
| oldDisplayType := operation_setting.GetGeneralSetting().QuotaDisplayType | ||
| t.Cleanup(func() { | ||
| common.QuotaPerUnit = oldQuotaPerUnit | ||
| operation_setting.GetGeneralSetting().QuotaDisplayType = oldDisplayType | ||
| }) | ||
|
|
||
| for _, quotaPerUnit := range []float64{0, -1, math.NaN(), math.Inf(1)} { | ||
| t.Run("invalid_quota_per_unit", func(t *testing.T) { | ||
| common.QuotaPerUnit = quotaPerUnit | ||
| operation_setting.GetGeneralSetting().QuotaDisplayType = operation_setting.QuotaDisplayTypeUSD | ||
|
|
||
| _, err := billingQuotaDisplayAmount(1000) | ||
|
|
||
| require.Error(t, err) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestBillingQuotaDisplayAmountAllowsTokenDisplayWithInvalidQuotaPerUnit(t *testing.T) { | ||
| oldQuotaPerUnit := common.QuotaPerUnit | ||
| oldDisplayType := operation_setting.GetGeneralSetting().QuotaDisplayType | ||
| t.Cleanup(func() { | ||
| common.QuotaPerUnit = oldQuotaPerUnit | ||
| operation_setting.GetGeneralSetting().QuotaDisplayType = oldDisplayType | ||
| }) | ||
|
|
||
| common.QuotaPerUnit = 0 | ||
| operation_setting.GetGeneralSetting().QuotaDisplayType = operation_setting.QuotaDisplayTypeTokens | ||
|
|
||
| amount, err := billingQuotaDisplayAmount(1000) | ||
|
|
||
| require.NoError(t, err) | ||
| require.Equal(t, 1000.0, amount) | ||
| } | ||
|
|
||
| func TestBillingQuotaDisplayAmountRejectsInvalidUSDExchangeRate(t *testing.T) { | ||
| oldQuotaPerUnit := common.QuotaPerUnit | ||
| oldDisplayType := operation_setting.GetGeneralSetting().QuotaDisplayType | ||
| oldUSDExchangeRate := operation_setting.USDExchangeRate | ||
| t.Cleanup(func() { | ||
| common.QuotaPerUnit = oldQuotaPerUnit | ||
| operation_setting.GetGeneralSetting().QuotaDisplayType = oldDisplayType | ||
| operation_setting.USDExchangeRate = oldUSDExchangeRate | ||
| }) | ||
|
|
||
| common.QuotaPerUnit = 500 | ||
| operation_setting.GetGeneralSetting().QuotaDisplayType = operation_setting.QuotaDisplayTypeCNY | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| usdExchangeRate float64 | ||
| }{ | ||
| {name: "zero", usdExchangeRate: 0}, | ||
| {name: "negative", usdExchangeRate: -1}, | ||
| {name: "nan", usdExchangeRate: math.NaN()}, | ||
| {name: "infinite", usdExchangeRate: math.Inf(1)}, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| operation_setting.USDExchangeRate = tt.usdExchangeRate | ||
|
|
||
| _, err := billingQuotaDisplayAmount(1000) | ||
|
|
||
| require.Error(t, err) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestBillingQuotaDisplayAmountAllowsValidUSDExchangeRate(t *testing.T) { | ||
| oldQuotaPerUnit := common.QuotaPerUnit | ||
| oldDisplayType := operation_setting.GetGeneralSetting().QuotaDisplayType | ||
| oldUSDExchangeRate := operation_setting.USDExchangeRate | ||
| t.Cleanup(func() { | ||
| common.QuotaPerUnit = oldQuotaPerUnit | ||
| operation_setting.GetGeneralSetting().QuotaDisplayType = oldDisplayType | ||
| operation_setting.USDExchangeRate = oldUSDExchangeRate | ||
| }) | ||
|
|
||
| common.QuotaPerUnit = 500 | ||
| operation_setting.USDExchangeRate = 7.2 | ||
| operation_setting.GetGeneralSetting().QuotaDisplayType = operation_setting.QuotaDisplayTypeCNY | ||
|
|
||
| amount, err := billingQuotaDisplayAmount(1000) | ||
|
|
||
| require.NoError(t, err) | ||
| require.Equal(t, 14.4, amount) | ||
| } | ||
|
|
||
| func TestBillingSubscriptionDisplayAmountAllowsUnlimitedTokenWithInvalidQuotaPerUnit(t *testing.T) { | ||
| oldQuotaPerUnit := common.QuotaPerUnit | ||
| oldDisplayType := operation_setting.GetGeneralSetting().QuotaDisplayType | ||
| t.Cleanup(func() { | ||
| common.QuotaPerUnit = oldQuotaPerUnit | ||
| operation_setting.GetGeneralSetting().QuotaDisplayType = oldDisplayType | ||
| }) | ||
|
|
||
| common.QuotaPerUnit = 0 | ||
| operation_setting.GetGeneralSetting().QuotaDisplayType = operation_setting.QuotaDisplayTypeUSD | ||
|
|
||
| amount, err := billingSubscriptionDisplayAmount(0, true) | ||
|
|
||
| require.NoError(t, err) | ||
| require.Equal(t, 100000000.0, amount) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.