fix(llm): classify zai token limit overflow (#35671)
This commit is contained in:
parent
78f85b1cd6
commit
adf178a6b9
3 changed files with 10 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ const patterns = [
|
||||||
/input is too long for requested model/i,
|
/input is too long for requested model/i,
|
||||||
/exceeds the context window/i,
|
/exceeds the context window/i,
|
||||||
/input token count.*exceeds the maximum/i,
|
/input token count.*exceeds the maximum/i,
|
||||||
|
/tokens in request more than max tokens allowed/i,
|
||||||
/maximum prompt length is \d+/i,
|
/maximum prompt length is \d+/i,
|
||||||
/reduce the length of the messages/i,
|
/reduce the length of the messages/i,
|
||||||
/maximum context length is \d+ tokens/i,
|
/maximum context length is \d+ tokens/i,
|
||||||
|
|
|
||||||
8
packages/llm/test/provider-error.test.ts
Normal file
8
packages/llm/test/provider-error.test.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { describe, expect, test } from "bun:test"
|
||||||
|
import { isContextOverflow } from "../src"
|
||||||
|
|
||||||
|
describe("provider error classification", () => {
|
||||||
|
test("classifies Z.AI GLM token limit messages as context overflow", () => {
|
||||||
|
expect(isContextOverflow("tokens in request more than max tokens allowed")).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
@ -1448,6 +1448,7 @@ describe("session.message-v2.fromError", () => {
|
||||||
"prompt is too long: 213462 tokens > 200000 maximum",
|
"prompt is too long: 213462 tokens > 200000 maximum",
|
||||||
"Your input exceeds the context window of this model",
|
"Your input exceeds the context window of this model",
|
||||||
"The input token count (1196265) exceeds the maximum number of tokens allowed (1048575)",
|
"The input token count (1196265) exceeds the maximum number of tokens allowed (1048575)",
|
||||||
|
"tokens in request more than max tokens allowed",
|
||||||
"Please reduce the length of the messages or completion",
|
"Please reduce the length of the messages or completion",
|
||||||
"400 status code (no body)",
|
"400 status code (no body)",
|
||||||
"413 status code (no body)",
|
"413 status code (no body)",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue