MCPcopy Create free account
hub / github.com/Noumena-Network/code / parsePromptTooLongTokenCounts

Function parsePromptTooLongTokenCounts

src/services/api/errors.ts:83–94  ·  view source on GitHub ↗
(rawMessage: string)

Source from the content-addressed store, hash-verified

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

Callers 3

detectPromptTooLongFunction · 0.85
getPromptTooLongTokenGapFunction · 0.85
errors.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected