qoder 0.2.60: the business record names the model (plugins#692, #638)
Qoder and Qoder CN booked every call as Auto whatever model_config named (chansee97, #692; square-235 on #638 after 0.2.54's model_config change did not help). The reference PR shuishuipingan/qoder2api-hub#119 says the official CLI's business block carries model_key. Checked in the client itself: @qoder-ai/qodercli 1.1.82 (npm pack, read only) builds the record in qoder-worker-runtime (v3 -> snn, then {..., model_key: <chosen model>}) and keeps it for the prompt. Qoder.app 0.4.3 and QwenWorkCN.app 1.0.46 on this Mac build theirs without it, so QwenWork's site says businessModelKey: false and is unchanged. qoderBody now adds business.model_key = the call's model key for qoder and qoder-cn. Run (mote): bun test packages/qoder, 388 pass. With the old index.mjs put back, the 6 new tests fail (business.model_key missing). bun scripts/check.mjs qoder. Not tried: a real Qoder or Qoder CN account, so the billing change is not confirmed; the attribution claim rests on the client's code and the PR's capture.
This commit is contained in:
@@ -1478,6 +1478,15 @@ function modelConfig(m, thinking) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The business record also names the model: Qoder's CLI (qodercli 1.1.82,
|
||||||
|
// qoder-worker-runtime v3 → snn + model_key) puts the chosen model's key
|
||||||
|
// there when a prompt starts, and the server attributes the call's billing
|
||||||
|
// from it. Without it Qoder and Qoder CN booked the call as Auto whatever
|
||||||
|
// model_config named (plugins#692, chansee97; the same shape as #638, where
|
||||||
|
// the model_config fix of 0.2.54 did not change the billing). Qoder.app
|
||||||
|
// 0.4.3 and QwenWork 1.0.46 build their record without it, so a site that
|
||||||
|
// ships such a client says businessModelKey: false.
|
||||||
|
//
|
||||||
// qoderBody is the plaintext agent_chat_generation takes for a chat
|
// qoderBody is the plaintext agent_chat_generation takes for a chat
|
||||||
// completion request, for model m, in the session the agent named (named,
|
// completion request, for model m, in the session the agent named (named,
|
||||||
// "" when none) and the task it is a call of (taskOf's, a new one when
|
// "" when none) and the task it is a call of (taskOf's, a new one when
|
||||||
@@ -1505,7 +1514,7 @@ function qoderBody(chat, m, named = "", task, site) {
|
|||||||
chat_record_id: request,
|
chat_record_id: request,
|
||||||
session_id: session,
|
session_id: session,
|
||||||
parameters: params,
|
parameters: params,
|
||||||
business: { product: site?.businessProduct ?? "app", version: site?.cosyVersion ?? COSY_VERSION, type: "agent", id: task.id, name: task.name ?? "", begin_at: task.begin, stage: task.answered ? "processing" : "start" },
|
business: { product: site?.businessProduct ?? "app", version: site?.cosyVersion ?? COSY_VERSION, type: "agent", id: task.id, name: task.name ?? "", begin_at: task.begin, stage: task.answered ? "processing" : "start", ...(site?.businessModelKey === false ? {} : { model_key: m.key }) },
|
||||||
agent_id: "agent_common",
|
agent_id: "agent_common",
|
||||||
task_id: "common",
|
task_id: "common",
|
||||||
session_type: site?.sessionType ?? "app",
|
session_type: site?.sessionType ?? "app",
|
||||||
@@ -2872,7 +2881,7 @@ const QWENWORK_COMMON = {
|
|||||||
deviceRefreshTarget: "c",
|
deviceRefreshTarget: "c",
|
||||||
clientHeaders: qwenworkClientHeaders,
|
clientHeaders: qwenworkClientHeaders,
|
||||||
modelScene: "qwork", listAllModels: true,
|
modelScene: "qwork", listAllModels: true,
|
||||||
clientType: "6", businessProduct: "qoder_work", sessionType: "qoder_work",
|
clientType: "6", businessProduct: "qoder_work", sessionType: "qoder_work", businessModelKey: false,
|
||||||
userInfoPath: "/api/v1/adapter/user/account-context?include=user,plan,quota,page,data_sharing",
|
userInfoPath: "/api/v1/adapter/user/account-context?include=user,plan,quota,page,data_sharing",
|
||||||
normalizeUser: v => (v?.data ?? v)?.user ?? (v?.data ?? v),
|
normalizeUser: v => (v?.data ?? v)?.user ?? (v?.data ?? v),
|
||||||
pat: false, // no /api/v1/jobToken/exchange on gateway.qwenwork.cn
|
pat: false, // no /api/v1/jobToken/exchange on gateway.qwenwork.cn
|
||||||
|
|||||||
@@ -87,3 +87,38 @@ test("a model the listing doesn't have is answered 400, with nothing sent", asyn
|
|||||||
expect(res.status).toBe(400)
|
expect(res.status).toBe(400)
|
||||||
expect(sent).toHaveLength(0)
|
expect(sent).toHaveLength(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// The business record names the model (plugins#692, chansee97; #638 again
|
||||||
|
// after 0.2.54): qodercli 1.1.82 sends business.model_key beside the
|
||||||
|
// product, version, type, id, name, begin_at and stage, and Qoder books the
|
||||||
|
// call from it. Without it Qoder and Qoder CN billed every model as Auto.
|
||||||
|
for (const [site, create, file] of [["qoder", QoderAuthPlugin, "listing.json"], ["qoder-cn", QoderCNAuthPlugin, "cn-listing-free-view.json"]]) {
|
||||||
|
for (const key of ["dfmodel", "kmodel_latest"]) {
|
||||||
|
test(`${site}: business.model_key is ${key}, the model the request names`, async () => {
|
||||||
|
const { res, sent } = await chatOn(create, paid(read(file)), key)
|
||||||
|
expect(res.status).toBe(200)
|
||||||
|
const b = sent.at(-1).business
|
||||||
|
expect(b.model_key).toBe(key)
|
||||||
|
expect(b.model_key).toBe(sent.at(-1).model_config.key)
|
||||||
|
expect(Object.keys(b)).toEqual(expect.arrayContaining(["product", "version", "type", "id", "name", "begin_at", "stage"]))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test("one task's calls on two models each name their own model", () => {
|
||||||
|
const listing = read("cn-listing-free-view.json")
|
||||||
|
const chat = { messages: [{ role: "user", content: "hi" }] }
|
||||||
|
const task = _internal.taskOf("s", chat)
|
||||||
|
const a = _internal.qoderBody({ ...chat, model: "dfmodel" }, _internal.modelInfo(listing.chat.find((e) => e.key === "dfmodel")), "s", task)
|
||||||
|
const b = _internal.qoderBody({ ...chat, model: "kmodel_latest" }, _internal.modelInfo(listing.chat.find((e) => e.key === "kmodel_latest")), "s", task)
|
||||||
|
expect(a.business.id).toBe(b.business.id)
|
||||||
|
expect([a.business.model_key, b.business.model_key]).toEqual(["dfmodel", "kmodel_latest"])
|
||||||
|
})
|
||||||
|
|
||||||
|
test("QwenWork's record stays as its own client builds it, with no model_key", () => {
|
||||||
|
const listing = read("cn-listing-free-view.json")
|
||||||
|
const df = _internal.modelInfo(listing.chat.find((e) => e.key === "dfmodel"))
|
||||||
|
const chat = { model: "dfmodel", messages: [{ role: "user", content: "hi" }] }
|
||||||
|
expect(_internal.qoderBody(chat, df, "", undefined, _internal.SITES.qwenwork).business).not.toHaveProperty("model_key")
|
||||||
|
expect(_internal.qoderBody(chat, df, "", undefined, _internal.SITES.qoder).business.model_key).toBe("dfmodel")
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user