Add configurable model hiding for pricing pages - #689
Merged
Conversation
Adds a `pricing_visibility_setting.hidden_models` option so specific models can be kept off the public pricing pages without disabling them. The option takes a comma-separated list of model names and supports `*` wildcards in prefix (`gpt-4o*`), suffix (`*-internal`), and contains (`*test*`) positions. Matching is case-insensitive and ignores blanks. Filtering is applied at the response boundary of every pricing payload: the authenticated console endpoint, the public website payload, and the PLG public-group payload. Hidden models stay fully callable through the relay and are still listed by /v1/models — this only affects what the pricing pages display. Changing the option fires a listener that clears the 5-minute website pricing response cache so edits take effect immediately. The listener lives in operation_setting because model/ cannot import controller/. The console gets a "Pricing Page Visibility" section under billing settings so the list can be edited without touching the database.
|
Reviewer feedback: the hidden-models control belongs next to the other model pricing controls, not in a separate billing section of its own. "Pricing Page Visibility" is removed as a standalone section and becomes a fourth "Hidden models" tab alongside Model prices / Tool prices / Upstream price sync, so everything that shapes what the pricing pages show now lives on one card. PricingVisibilitySection is replaced by HiddenModelsSettings under models/. The old component wrapped itself in SettingsSection, which would have nested inside the card's own section; the sibling tab bodies (ToolPriceSettings, UpstreamRatioSync) render bare content, so the new component matches that shape. RatioSettingsCard gains the tab id, its label, a grid-cols-5 entry, and a hiddenModelsDefault prop. Also adds the i18n keys this feature needs across all 8 locales — the previous commit introduced user-visible strings without them, so they would have silently fallen back to English.
Collaborator
Author
更新:隐藏模型配置改为 Model Pricing 的第 4 个标签页按反馈调整了控件位置 —— 隐藏模型属于模型定价的一部分,不该单占一个计费分区。 改动 移除独立的
补上遗漏的 i18n 上一个 commit 引入了用户可见文案却没加翻译 key( 跑过 验证
部署
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
背景
flatkey.ai/zh/models、/zh/pricing以及控制台定价页的模型列表,都来自同一条链路(model.GetPricing()→ 两个 pricing 接口)。此前没有任何机制可以把个别模型从展示中摘掉——唯一手段是把models表的status改成非 1,但那是全局禁用,控制台也一起看不见。改动
新增配置项
pricing_visibility_setting.hidden_models,逗号分隔模型名,支持*通配:gpt-4ogpt-4o**-internal*test**大小写不敏感,自动忽略空项、去重。
过滤挂在所有定价出口:
GetPricing(控制台,带鉴权)buildWebsitePricingPayloadDefault(官网默认)buildWebsitePublicGroupPricingPayload(PLG 公开分组)不影响调用:隐藏的模型照常走 relay,
/v1/models仍会列出。这里只管定价页展示。缓存即时失效:改配置会触发监听器清掉 5 分钟的
websitePricingCache。因为model不能反向 importcontroller,回调注册放在operation_setting(OnPricingVisibilityChanged)。控制台 UI:计费设置下新增「Pricing Page Visibility」分区,多行文本框直接编辑,无需碰数据库。
验证
go test ./controller/ -run Pricing15 个定价测试全绿,含 main 上既有的 11 个go test ./setting/operation_setting/全绿go vet干净,前端tsc -b通过说明:
controller包里 asset-task / CLI device auth / user token / channel error 几个测试在未改动的 main 上同样失败(已 stash 对照验证),与本 PR 无关。注意
官网侧还有 Next.js 的 5 分钟 ISR 缓存,改完最多 5 分钟生效;控制台是即时的。