Download packages/llm/test/provider-error.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/llm/test/provider-error.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/llm/test/provider-error.test.ts
-
curl -L -o provider-error.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/llm/test/provider-error.test.ts
1.31 kB
| import { describe, expect, test } from "bun:test" | |
| import { isContextOverflow } from "../src" | |
| describe("provider error classification", () => { | |
| test("classifies provider token limit messages as context overflow", () => { | |
| const messages = [ | |
| "tokens in request more than max tokens allowed", | |
| '{"error":{"type":"request_too_large","message":"Request exceeds the maximum size"}}', | |
| "Requested token count exceeds the model's maximum context length of 131072 tokens.", | |
| "Input length (265330) exceeds model's maximum context length (262144).", | |
| "Input length 131393 exceeds the maximum allowed input length of 131040 tokens.", | |
| "The input (516368 tokens) is longer than the model's context length (262144 tokens).", | |
| "Prompt has 5,958,968 tokens, but the configured context size is 256,000 tokens", | |
| "Too many tokens", | |
| "Token limit exceeded", | |
| ] | |
| expect(messages.every(isContextOverflow)).toBe(true) | |
| }) | |
| test("does not classify rate limits as context overflow", () => { | |
| const messages = [ | |
| "Throttling error: Too many tokens, please wait before trying again.", | |
| "Rate limit exceeded, please retry after 30 seconds.", | |
| "Too many requests. Please slow down.", | |
| ] | |
| expect(messages.some(isContextOverflow)).toBe(false) | |
| }) | |
| }) | |