chore(ab-corpus): route glm-5.1 + kimi-k2.6 through 方舟 CP (Ark)
Volcengine 方舟 (Ark) added GLM-5.1 and Kimi-K2.6 to its coding
plan on 2026-04-22 — single ARK_CODING_KEY covers both. Harness
now prefers this route over the previous paths:
- glm-5.1 was routed to clients/glm.ts (GLM official CP via
open.bigmodel.cn with GLM_OFFICIAL_CODING_KEY). Now routed to
new clients/ark.ts. The old glm.ts file is kept on disk for
historical comparison but not wired into the default router —
callers who want to A/B the old GLM-official path vs. new Ark
path can import callGlm directly.
- kimi-k2.6 is new — added as a dedicated router branch above
the kimi-k2.5 (bailian) branch so the version-specific match
lands on Ark.
Old kimi-k2.5 continues to route through clients/bailian.ts
(DashScope aggregator) for continuity with earlier A/B runs.
Key management (unchanged from the harness convention):
- ARK_CODING_KEY — Volcengine 方舟 CP UUID format key. Export
in shell before running --live; never committed.
- Existing MINIMAX_API_KEY / GLM_OFFICIAL_CODING_KEY /
DASHSCOPE_BAILIAN_CODING_KEY all still honored for their
respective routes.
Throw message updated so missing-key errors surface the correct
env var for each route.
This commit is contained in:
parent
dd5d156160
commit
5538350a2f
46
scripts/ab-corpus/clients/ark.ts
Normal file
46
scripts/ab-corpus/clients/ark.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* 方舟 (Volcengine Ark) Coding Plan wrapper. One API key covers
|
||||
* multiple third-party models hosted on Ark's coding tier —
|
||||
* currently GLM-5.1 and KIMI-K2.6. Cribbed from builtin-provider-
|
||||
* presets.ts `ark-coding` preset.
|
||||
*
|
||||
* Default baseURL: https://ark.cn-beijing.volces.com/api/coding/v3
|
||||
* Override via `ARK_BASE_URL` if Volcengine ever ships a regional
|
||||
* variant (none published as of 2026-04-22).
|
||||
*
|
||||
* Key env var: `ARK_CODING_KEY` — Volcengine's UUID-format ARK
|
||||
* access key. NOT committed to the repo; export in your shell
|
||||
* before running `bun scripts/ab-corpus/run.ts --live`.
|
||||
*/
|
||||
|
||||
import { callOpenAICompat } from './openai-compat';
|
||||
|
||||
const ARK_BASE_URL = process.env.ARK_BASE_URL ?? 'https://ark.cn-beijing.volces.com/api/coding/v3';
|
||||
const ARK_API_KEY_ENV = 'ARK_CODING_KEY';
|
||||
|
||||
export interface CallArkArgs {
|
||||
model: string;
|
||||
system: string;
|
||||
user: string;
|
||||
temperature?: number;
|
||||
maxTokens?: number;
|
||||
}
|
||||
|
||||
export async function callArk(args: CallArkArgs): Promise<string> {
|
||||
const apiKey = process.env[ARK_API_KEY_ENV];
|
||||
if (!apiKey) {
|
||||
throw new Error(
|
||||
`${ARK_API_KEY_ENV} not set — export it (Volcengine 方舟 CP UUID key) before running with --live`,
|
||||
);
|
||||
}
|
||||
return callOpenAICompat({
|
||||
baseURL: ARK_BASE_URL,
|
||||
apiKey,
|
||||
model: args.model,
|
||||
system: args.system,
|
||||
user: args.user,
|
||||
temperature: args.temperature,
|
||||
maxTokens: args.maxTokens,
|
||||
label: 'ark',
|
||||
});
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
import { callMinimax } from './clients/minimax';
|
||||
import { callCodex } from './clients/codex-cli';
|
||||
import { callBailian } from './clients/bailian';
|
||||
import { callGlm } from './clients/glm';
|
||||
import { callArk } from './clients/ark';
|
||||
import { buildSystemPrompt } from './build-prompt';
|
||||
import type { ModelCall } from './stub-model';
|
||||
|
||||
|
|
@ -24,15 +24,31 @@ import type { ModelCall } from './stub-model';
|
|||
*
|
||||
* - `minimax*` → clients/minimax.ts (MINIMAX_API_KEY)
|
||||
* - `gpt-*` / o* → clients/codex-cli.ts (Codex CLI subscription)
|
||||
* - `glm-5.1` → clients/glm.ts (GLM_OFFICIAL_CODING_KEY,
|
||||
* GLM-official coding-plan endpoint)
|
||||
* - `glm-5.1` → clients/ark.ts (ARK_CODING_KEY;
|
||||
* Volcengine 方舟 now hosts
|
||||
* GLM-5.1 on its coding plan
|
||||
* as of 2026-04-22. Replaces
|
||||
* the earlier GLM-official
|
||||
* CP route via open.bigmodel.cn
|
||||
* — clients/glm.ts is kept on
|
||||
* disk for historical reference
|
||||
* but no longer auto-routed.)
|
||||
* - `kimi-k2.6` → clients/ark.ts (ARK_CODING_KEY; Volcengine
|
||||
* added K2.6 to 方舟 CP on
|
||||
* 2026-04-22)
|
||||
* - `glm-*` → clients/bailian.ts (DASHSCOPE_BAILIAN_CODING_KEY,
|
||||
* earlier GLM versions hosted on
|
||||
* Bailian's DashScope aggregator)
|
||||
* - `kimi-*` → clients/bailian.ts (DASHSCOPE_BAILIAN_CODING_KEY,
|
||||
* Kimi K-series also on Bailian)
|
||||
* Kimi K2.5 and earlier on Bailian)
|
||||
*
|
||||
* Anything else → throw with the supported list.
|
||||
*
|
||||
* When benchmarking across routes (e.g. to compare the new Ark GLM-5.1
|
||||
* vs. the legacy GLM-official route), import `callGlm` from
|
||||
* `./clients/glm.ts` directly and wire it here under a different model
|
||||
* alias (say `glm-5.1-legacy`). The default router picks Ark because
|
||||
* that's the path we're actively promoting.
|
||||
*/
|
||||
export async function realModelCall(call: ModelCall): Promise<string> {
|
||||
const built = buildSystemPrompt(call.variant);
|
||||
|
|
@ -50,8 +66,15 @@ export async function realModelCall(call: ModelCall): Promise<string> {
|
|||
return callCodex({ model, system: built.system, user });
|
||||
}
|
||||
if (/^glm-5\.1/i.test(model)) {
|
||||
return callGlm({
|
||||
model: mapGlmOfficialId(model),
|
||||
return callArk({
|
||||
model: mapGlmArkId(model),
|
||||
system: built.system,
|
||||
user,
|
||||
});
|
||||
}
|
||||
if (/^kimi-k2\.6/i.test(model)) {
|
||||
return callArk({
|
||||
model: mapKimiArkId(model),
|
||||
system: built.system,
|
||||
user,
|
||||
});
|
||||
|
|
@ -71,7 +94,7 @@ export async function realModelCall(call: ModelCall): Promise<string> {
|
|||
});
|
||||
}
|
||||
throw new Error(
|
||||
`No live adapter for model "${model}". Supported: minimax-* (MINIMAX_API_KEY), gpt-*/o1/o3/o4 (Codex CLI), glm-5.1 (GLM_OFFICIAL_CODING_KEY), glm-5 / kimi-* (DASHSCOPE_BAILIAN_CODING_KEY).`,
|
||||
`No live adapter for model "${model}". Supported: minimax-* (MINIMAX_API_KEY), gpt-*/o1/o3/o4 (Codex CLI), glm-5.1 / kimi-k2.6 (ARK_CODING_KEY), glm-5 / kimi-k2.5 (DASHSCOPE_BAILIAN_CODING_KEY).`,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -84,14 +107,38 @@ function mapMinimaxId(id: string): string {
|
|||
}
|
||||
|
||||
function mapGlmOfficialId(id: string): string {
|
||||
// GLM official CP ships "glm-4.7" as the current coding model
|
||||
// (per builtin-provider-presets.ts modelPlaceholder). User's
|
||||
// preferred short form "glm-5.1" maps to that id here.
|
||||
// GLM official CP (open.bigmodel.cn) used to ship "glm-4.7" as the
|
||||
// current coding model. The harness no longer routes `glm-5.1` here
|
||||
// (Ark took over, see mapGlmArkId) but this mapper is kept so
|
||||
// callers who manually import `./clients/glm.ts` for A/B comparison
|
||||
// can still get the canonical id.
|
||||
const lower = id.toLowerCase();
|
||||
if (lower === 'glm-5.1' || lower === 'glm-5.1-coding') return 'glm-4.7';
|
||||
return id;
|
||||
}
|
||||
|
||||
function mapGlmArkId(id: string): string {
|
||||
// 方舟 CP exposes Zhipu GLM-5.1 on the coding-plan endpoint. The
|
||||
// on-Ark model name is "glm-5.1" verbatim (no endpoint-ID alias
|
||||
// required as of 2026-04-22 — earlier Ark models needed `ep-xxx`
|
||||
// but GLM-5.1 was onboarded with the promoted short name).
|
||||
const lower = id.toLowerCase();
|
||||
if (lower === 'glm-5.1' || lower === 'glm-5.1-coding' || lower === 'glm-5.1-ark') {
|
||||
return 'glm-5.1';
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
function mapKimiArkId(id: string): string {
|
||||
// 方舟 CP exposes Moonshot Kimi K2.6 on the coding-plan endpoint.
|
||||
// Volcengine accepts the promoted short name `kimi-k2.6` directly.
|
||||
const lower = id.toLowerCase();
|
||||
if (lower === 'kimi-k2.6' || lower === 'kimi-2.6' || lower === 'kimi-k2.6-ark') {
|
||||
return 'kimi-k2.6';
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
function mapGlmBailianId(id: string): string {
|
||||
return mapGlmBailianIdInternal(id);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue