(rawMessage: string)
| 83 | * have different casing (Vertex), so this is intentionally lenient. |
| 84 | */ |
| 85 | export function parsePromptTooLongTokenCounts(rawMessage: string): { |
| 86 | actualTokens: number | undefined |
| 87 | limitTokens: number | undefined |
| 88 | } { |
| 89 | const match = rawMessage.match( |
| 90 | /prompt is too long[^0-9]*(\d+)\s*tokens?\s*>\s*(\d+)/i, |
| 91 | ) |
| 92 | return { |
| 93 | actualTokens: match ? parseInt(match[1]!, 10) : undefined, |
| 94 | limitTokens: match ? parseInt(match[2]!, 10) : undefined, |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Returns how many tokens over the limit a prompt-too-long error reports, |
no outgoing calls
no test coverage detected