From 87332fe9d13695d0c7637793a66cba851775faad Mon Sep 17 00:00:00 2001 From: fylorn <249551762+fylorn@users.noreply.github.com> Date: Mon, 14 Sep 2026 14:52:35 +0800 Subject: [PATCH] chore: English for everything GitHub renders publicly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Workflow names, step names and CI log output show up in the Actions tab and in pull request annotations on a public repository. Those were still Chinese; this switches them over, along with `PROVENANCE.md`, which sits next to an English README and CONTRIBUTING. Comments inside the sources stay Chinese. That is the existing convention throughout this codebase and it is deliberate — the split is between what GitHub renders to anyone browsing the repo and what a reader of the source sees. The one coupling worth knowing about: `pricing.yml` reads the snapshot date straight out of the `PROVENANCE.md` table with grep -oE 'Snapshot date \| [0-9-]+' so the table header and that pattern have to move together. They did, and both greps were run against the rewritten file — the date and the pinned SHA come back identical to before. The failure mode otherwise is quiet: the workflow only warns, so a broken pattern would not turn anything red, it would just stop telling anyone the table had gone stale. Co-Authored-By: Claude Opus 5 --- .github/workflows/ci.yml | 8 ++-- .github/workflows/pricing.yml | 18 ++++----- crates/tw-pricing/data/PROVENANCE.md | 56 +++++++++++++++------------- 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b05e3f1..9466e0e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 - - name: 格式 + - name: Format run: cargo fmt --all -- --check - name: clippy @@ -33,14 +33,14 @@ jobs: # 默认不跑打真实网络的那些(它们标了 #[ignore])—— CI 上的网络 # 抖动会变成一条和代码无关的红,而那种红看几次就没人看了。 - - name: 测试 + - name: Test run: cargo test --workspace - - name: 构建 + - name: Build run: cargo build --release -p twcore # **接缝上的失败模式单元测试看不见**:文件权限、socket、某个端点 # 在真二进制上根本没注册。这个项目的前四个真 bug 都是这么被逮到的 # (DESIGN.md §9.7)。脚本自己会 build,这一步只是跑它。 - - name: 冒烟(真二进制、真 socket、真数据面) + - name: Smoke (real binary, real socket, real data plane) run: ./scripts/smoke.sh diff --git a/.github/workflows/pricing.yml b/.github/workflows/pricing.yml index 335801d3..63b4da48 100644 --- a/.github/workflows/pricing.yml +++ b/.github/workflows/pricing.yml @@ -6,7 +6,7 @@ # 这个 workflow 只回答另一个问题:**内置快照放了多久了。**任何第三方 # 数据源都会滞后,而一份三个月前的快照算出来的「今日花费」,和一份上周 # 的,可信度完全不同。 -name: 价目表新鲜度 +name: Pricing freshness on: schedule: @@ -20,29 +20,29 @@ jobs: steps: - uses: actions/checkout@v4 - - name: 看看内置快照放了多久 + - name: How old is the bundled snapshot run: | set -euo pipefail - SNAP=$(grep -oE '快照日期 \| [0-9-]+' crates/tw-pricing/data/PROVENANCE.md | grep -oE '[0-9-]+$') + SNAP=$(grep -oE 'Snapshot date \| [0-9-]+' crates/tw-pricing/data/PROVENANCE.md | grep -oE '[0-9-]+$') AGE=$(( ( $(date +%s) - $(date -d "$SNAP" +%s) ) / 86400 )) - echo "内置快照日期:$SNAP($AGE 天前)" + echo "Bundled snapshot: $SNAP ($AGE days old)" # 上游那份文件几乎天天在动,但价格变动是月级的。30 天是个 # 「该看一眼了」的信号,不是「一定过期了」。 if [ "$AGE" -gt 30 ]; then - echo "::warning::内置价目表已经 $AGE 天没更新了。更新步骤见 crates/tw-pricing/data/PROVENANCE.md" + echo "::warning::The bundled price table is $AGE days old. Steps to refresh it are in crates/tw-pricing/data/PROVENANCE.md" fi - - name: 上游有没有新版本 + - name: Does upstream have a newer revision run: | set -euo pipefail PINNED=$(grep -oE '`[0-9a-f]{40}`' crates/tw-pricing/data/PROVENANCE.md | tr -d '`' | head -1) LATEST=$(curl -sS "https://api.github.com/repos/BerriAI/litellm/commits?path=model_prices_and_context_window.json&per_page=1" \ | python3 -c 'import json,sys; print(json.load(sys.stdin)[0]["sha"])') - echo "我们 pin 的:$PINNED" - echo "上游最新的:$LATEST" + echo "pinned: $PINNED" + echo "upstream: $LATEST" if [ "$PINNED" != "$LATEST" ]; then # **不自动更新。**§4.3.0:pin 到具体的 commit,不要用 main —— # 自动跟随意味着两次构建可能拿到不同的价格,而「昨天算出来的 # 钱和今天不一样」是没法解释的。 - echo "::warning::上游有新版本了。要更新的话,按 PROVENANCE.md 的步骤来,并**重新核对 verified.yaml**" + echo "::warning::Upstream has a newer revision. To take it, follow PROVENANCE.md and re-verify verified.yaml against the vendors' own pricing pages" fi diff --git a/crates/tw-pricing/data/PROVENANCE.md b/crates/tw-pricing/data/PROVENANCE.md index eb29cb63..0c757f08 100644 --- a/crates/tw-pricing/data/PROVENANCE.md +++ b/crates/tw-pricing/data/PROVENANCE.md @@ -1,44 +1,50 @@ -# 内置价目表的来历 +# Where the bundled price table comes from | | | |---|---| -| 来源 | https://github.com/BerriAI/litellm — `model_prices_and_context_window.json`(仓库根目录那份) | -| commit | `ee7c7e14f3dd7c4c3930a423440ec26427e2c554` | -| 快照日期 | 2026-09-09 | -| 许可 | MIT(**根目录那份**。`enterprise/` 下的例外不适用于它)| -| 原始大小 | 2343859 字节,gzip 后 110309 字节 | -| 模型数 | 3860 | +| Source | https://github.com/BerriAI/litellm — `model_prices_and_context_window.json` (the copy at the repository root) | +| Commit | `ee7c7e14f3dd7c4c3930a423440ec26427e2c554` | +| Snapshot date | 2026-09-09 | +| License | MIT (**the root copy**. The exceptions under `enterprise/` do not apply to it) | +| Raw size | 2343859 bytes, 110309 gzipped | +| Models | 3860 | -## 为什么是它 +## Why this source -DESIGN.md §4.3.0 里那个决定性的字段: +The field that decided it (DESIGN.md §4.3.0): ``` cache_creation_input_token_cost_above_1hr ``` -**它是公开数据集里唯一编码了 Anthropic「1 小时缓存写入」价格的。**其他 -候选都只有 5 分钟档 —— Sonnet 4.5 是 5 分钟 $3.75、1 小时 $6.00,用户 -开 1 小时 TTL 就会被**系统性低估 60%**。而低估比不知道更糟:它看起来是 -个确定的数字。 +**It is the only public dataset that encodes Anthropic's 1-hour cache write +price.** Every other candidate carries the 5-minute tier alone — Sonnet 4.5 is +$3.75 at 5 minutes and $6.00 at 1 hour, so anyone running a 1-hour TTL is +**systematically underestimated by 60%**. An underestimate is worse than not +knowing: it arrives looking like a definite number. -## 怎么更新 +## How to update it -**pin 到具体的 commit SHA,不要用 `main`。**`main` 意味着两次构建 -可能拿到不同的价格,而「昨天算出来的钱和今天不一样」是没法解释的。 +**Pin a specific commit SHA, never `main`.** Following `main` means two builds +can pick up different prices, and "yesterday's figure does not match today's" +is not something anyone can explain. ```bash -# 找到最新的 commit +# find the latest commit curl -s "https://api.github.com/repos/BerriAI/litellm/commits?path=model_prices_and_context_window.json&per_page=1" -# 拉那一版并压缩 +# fetch that revision and compress it curl -sL "https://raw.githubusercontent.com/BerriAI/litellm//model_prices_and_context_window.json" \ | gzip -9 > crates/tw-pricing/data/model_prices.json.gz ``` -然后**更新这个文件里的 SHA 和日期**,并跑发版前的双源交叉校验(§4.3.0): -对十几个主力模型,逐条比对**厂商官方定价页** —— 不是和另一个第三方数据集 -对,那只是把赌注换个地方押。 - -一个实测到的例子:OpenAI 在 2026-08-22 下调了某个模型的价格,某个广泛 -使用的数据集**三天后才修正**,中间一直返回偏高 25% 的价格。根因是那家的 -同步脚本只自动同步模型清单,价格靠人工 PR。 +Then **update the SHA and the date in this file** — the freshness workflow +reads both straight out of the table above — and run the two-source +cross-check before release (§4.3.0): for the dozen or so models people +actually use, compare line by line against **the vendor's own pricing page**. +Not against a second third-party dataset; that only moves the bet somewhere +else. + +One measured example. OpenAI cut the price of a model on 2026-08-22, and a +widely used dataset **did not correct it for three days**, returning a figure +25% too high the whole time. The cause was that their sync script automates +the model list but not the prices, which arrive by hand-written PR.