|
|
|
|
@@ -16,6 +16,7 @@ import type { AssistantMessage } from "../types.ts";
|
|
|
|
|
* - xAI: "This model's maximum prompt length is 131072 but the request contains 537812 tokens"
|
|
|
|
|
* - Groq: "Please reduce the length of the messages or completion"
|
|
|
|
|
* - OpenRouter: "This endpoint's maximum context length is X tokens. However, you requested about Y tokens"
|
|
|
|
|
* - OpenRouter/Poolside: "Input length X exceeds the maximum allowed input length of Y tokens."
|
|
|
|
|
* - Together AI: "The input (X tokens) is longer than the model's context length (Y tokens)."
|
|
|
|
|
* - llama.cpp: "the request exceeds the available context size, try increasing it"
|
|
|
|
|
* - LM Studio: "tokens to keep from the initial prompt is greater than the context length"
|
|
|
|
|
@@ -39,7 +40,8 @@ const OVERFLOW_PATTERNS = [
|
|
|
|
|
/input token count.*exceeds the maximum/i, // Google (Gemini)
|
|
|
|
|
/maximum prompt length is \d+/i, // xAI (Grok)
|
|
|
|
|
/reduce the length of the messages/i, // Groq
|
|
|
|
|
/maximum context length is \d+ tokens/i, // OpenRouter (all backends)
|
|
|
|
|
/maximum context length is \d+ tokens/i, // OpenRouter (most backends)
|
|
|
|
|
/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i, // OpenRouter/Poolside
|
|
|
|
|
/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i, // Together AI
|
|
|
|
|
/exceeds the limit of \d+/i, // GitHub Copilot
|
|
|
|
|
/exceeds the available context size/i, // llama.cpp server
|
|
|
|
|
@@ -89,7 +91,8 @@ const NON_OVERFLOW_PATTERNS = [
|
|
|
|
|
* - Groq: "reduce the length of the messages"
|
|
|
|
|
* - Cerebras: 400/413 status code (no body)
|
|
|
|
|
* - Mistral: "Prompt contains X tokens ... too large for model with Y maximum context length"
|
|
|
|
|
* - OpenRouter (all backends): "maximum context length is X tokens"
|
|
|
|
|
* - OpenRouter (most backends): "maximum context length is X tokens"
|
|
|
|
|
* - OpenRouter/Poolside: "Input length X exceeds the maximum allowed input length of Y tokens."
|
|
|
|
|
* - Together AI: "The input (X tokens) is longer than the model's context length (Y tokens)."
|
|
|
|
|
* - llama.cpp: "exceeds the available context size"
|
|
|
|
|
* - LM Studio: "greater than the context length"
|
|
|
|
|
|