codearts 0.3.15: stop goes to the gateway as a string, an empty one not at all (Abandon332 on X, magpie#6342)
Huawei's gateway takes `stop` as a string only. Any array, [] too, came back as HTTP 200 with InferHub.001001005.400 "The request param is invalid", which magpie read as a plain 400 and rested the account for (182 times in the report). prepareChatBody now sends the first non-empty string of a list, and drops an empty or blank one or a value of another kind. Run: bun test packages/codearts (204 pass). Broke it by hand: with the normalizeStop call commented out the new test is red. Not tried: a real CodeArts account (the reporter's table is the evidence).
This commit is contained in:
@@ -244,6 +244,15 @@ test("a dated model only the agent lists keeps its date, named or not (#677)", a
|
||||
assert.equal(names["deepseek-v4.1-flash-0930"], "Deepseek V4.1 Flash 0930")
|
||||
})
|
||||
|
||||
test("stop goes as the string the gateway takes, and an empty one not at all (magpie#6342)", () => {
|
||||
const stop = (v) => x.prepareChatBody({ model: "GLM-5.2", messages: [], stop: v }).body
|
||||
assert.equal(stop(["\n\n"]).stop, "\n\n")
|
||||
assert.equal(stop(["", "###", "Observation:"]).stop, "###")
|
||||
assert.equal(stop("###").stop, "###")
|
||||
for (const v of [[], [""], [null, 3], "", null, 7]) assert.equal("stop" in stop(v), false, JSON.stringify(v))
|
||||
assert.equal("stop" in x.prepareChatBody({ model: "GLM-5.2", messages: [] }).body, false)
|
||||
})
|
||||
|
||||
test("prepareChatBody reshapes a chat into what the gateway accepts and meters", () => {
|
||||
const out = x.prepareChatBody({ model: "codearts/GLM-5.2", messages: [], max_tokens: 128000 })
|
||||
assert.equal(out.fold, true)
|
||||
|
||||
Reference in New Issue
Block a user