refactor(render3d): 报价只留积分,删掉供应商单价与人民币换算 - #547
Open
johnnyzhang-eng wants to merge 1 commit into
Open
Conversation
quote() 的第二个返回值全仓无消费方;单价 0.12 是采购成本,不该留在公开仓。 三处 SpendNotAuthorized 文案改为只报积分。 Closes 1024XEngineer#546
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
本次改动把两个 provider 的 quote() 契约、消费授权异常和 orchestrator 报价统一为只返回/展示积分;调用链与测试断言整体一致。不过 provider 文档仍残留供应商单价和旧返回值说明,因此当前提交还没有完整实现 #546 所述的公开仓清理目标。
验证:追踪了仓内全部 quote() 调用方;py_compile 与固定 SHA 范围的 git diff --check 通过。当前环境未安装 uv/pytest,未能复跑 pytest。
Additional findings
backend/packages/framework/src/windup_framework/providers/render3d/tencent.py:10: [P1] 删除模块说明中残留的供应商单价: 模块说明仍明确写着供应商“后付费 0.12 元/积分”,所以即使CREDIT_PRICE_CNY常量和人民币换算已删除,公开仓依然保留了 #546 要清理的采购成本;rg '0\.12 元/积分' backend/packages仍会命中这里。请将这段改为只描述产品积分,或完全移除供应商价格。
|
|
||
| def quote(self, n_views: int = 1) -> tuple[int, float]: | ||
| def quote(self, n_views: int = 1) -> int: | ||
| """返回 (积分, 预估元)。PBR、多视图各 +10 积分。纯计算,可在提交前随便调。""" |
Contributor
There was a problem hiding this comment.
[P2] 将 quote 文档同步为单个积分返回值
这里的签名和实现已改为返回 int,但 docstring 仍承诺返回 (积分, 预估元)。任何按实现文档调用或解包返回值的使用方都会得到错误指引;请把说明改成仅返回积分,并删除“预估元”。
| RIG_CREDITS = 10 | ||
| CREDIT_PRICE_CNY = 0.12 # 后付费单价;预付费 0.09–0.1 | ||
| MAX_IMAGE_BYTES = 6 * 10**6 # ImageBase64 上限 | ||
| VIEW_TYPES = ("back", "left", "right") # 正面走主参数,不在这里 |
Contributor
There was a problem hiding this comment.
这块我觉得可以统一走配置?
你看看是否可以将这些东西放在.env中?而不是在代码中写死?
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.
Closes #546
问题
#482 把人民币金额从出参里删掉了,还加了反向断言「人民币金额不出参 —— 那是我们的成本,不是用户的价钱」。但它只覆盖了
render3d_service.py一侧,供应商单价与换算留在别处:tencent.py:CREDIT_PRICE_CNY = 0.12 # 后付费单价;预付费 0.09–0.1,两个quote()返回(积分, 人民币)render3d_assets.py:BUILD_CNY,以及一句带约 ¥{BUILD_CNY}的文案render3d_service.py:另一句同样带约 ¥{BUILD_CNY}本仓是公开仓,
0.12是付给供应商的后付费单价,注释里还写了预付费区间。不把问题说重:这几处目前不会到用户眼前。它们抛
SpendNotAuthorized(ValueError子类),而_failure.user_message没有对应分支、会落到通用文案。所以不是外泄事故,是两件事——公开仓里留着采购成本,以及一段没有消费方的换算(quote()的第二个返回值全仓无人读取,grep 确认)。方案
删掉
CREDIT_PRICE_CNY与派生的BUILD_CNY;quote()只返回积分(tuple[int, float]→int);三处文案只报积分。积分定价(CREDITS/RIG_CREDITS/BUILD_CREDITS)是产品价,一律不动。不包含
_failure.user_message的兜底行为验收
packages/下grep "¥\|CNY"无命中。两条既有用例改成锁新契约,其中一条加了反向断言assert "¥" not in str(e.value);把¥加回文案时它失败:ruff check .、lint-imports(2 kept, 0 broken)、export_openapi后openapi.json无漂移、pytest -q(1317 passed, 14 skipped)。