Download src/agents/embedded-agent-helpers/image-errors.ts from SaylorTwift/openclaw: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/SaylorTwift/openclaw/resolve/main/src/agents/embedded-agent-helpers/image-errors.ts
- Command line
-
hf download hf://SaylorTwift/openclaw/src/agents/embedded-agent-helpers/image-errors.ts
-
curl -L -o image-errors.ts https://huggingface.co/SaylorTwift/openclaw/resolve/main/src/agents/embedded-agent-helpers/image-errors.ts
1.54 kB
| const IMAGE_DIMENSION_ERROR_RE = | |
| /image dimensions exceed max allowed size for many-image requests:\s*(\d+)\s*pixels/i; | |
| const IMAGE_DIMENSION_PATH_RE = /messages\.(\d+)\.content\.(\d+)\.image/i; | |
| const IMAGE_SIZE_ERROR_RE = /image exceeds\s*(\d+(?:\.\d+)?)\s*mb/i; | |
| export function parseImageDimensionError(raw: string): { | |
| maxDimensionPx?: number; | |
| messageIndex?: number; | |
| contentIndex?: number; | |
| raw: string; | |
| } | null { | |
| if (!raw) { | |
| return null; | |
| } | |
| if (!/image dimensions exceed max allowed size/i.test(raw)) { | |
| return null; | |
| } | |
| const limitMatch = raw.match(IMAGE_DIMENSION_ERROR_RE); | |
| const pathMatch = raw.match(IMAGE_DIMENSION_PATH_RE); | |
| return { | |
| maxDimensionPx: limitMatch?.[1] ? Number.parseInt(limitMatch[1], 10) : undefined, | |
| messageIndex: pathMatch?.[1] ? Number.parseInt(pathMatch[1], 10) : undefined, | |
| contentIndex: pathMatch?.[2] ? Number.parseInt(pathMatch[2], 10) : undefined, | |
| raw, | |
| }; | |
| } | |
| export function isImageDimensionErrorMessage(raw: string): boolean { | |
| return Boolean(parseImageDimensionError(raw)); | |
| } | |
| export function parseImageSizeError(raw: string): { | |
| maxMb?: number; | |
| raw: string; | |
| } | null { | |
| if (!raw) { | |
| return null; | |
| } | |
| if (!/image exceeds[\s\S]*mb/i.test(raw)) { | |
| return null; | |
| } | |
| const match = raw.match(IMAGE_SIZE_ERROR_RE); | |
| return { | |
| maxMb: match?.[1] ? Number.parseFloat(match[1]) : undefined, | |
| raw, | |
| }; | |
| } | |
| export function isImageSizeError(errorMessage?: string): boolean { | |
| return Boolean(errorMessage && parseImageSizeError(errorMessage)); | |
| } | |