Spaces:
Sleeping
Sleeping
Download src/workflow/problem-framing/retry.ts from Bin29/ManimCat-show: direct link, hf CLI and curl.
- Browser
- Download file 642 Bytes
-
https://huggingface.co/spaces/Bin29/ManimCat-show/resolve/main/src/workflow/problem-framing/retry.ts
- Command line
-
hf download hf://spaces/Bin29/ManimCat-show/src/workflow/problem-framing/retry.ts
-
curl -L -o retry.ts https://huggingface.co/spaces/Bin29/ManimCat-show/resolve/main/src/workflow/problem-framing/retry.ts
642 Bytes
| export interface ProblemFramingImageFallbackOptions<T> { | |
| hasReferenceImages: boolean | |
| execute: (useImages: boolean) => Promise<T> | |
| shouldRetryWithoutImages: (error: unknown) => boolean | |
| onImageFallback?: (error: unknown) => void | |
| } | |
| export async function executeProblemFramingWithImageFallback<T>( | |
| options: ProblemFramingImageFallbackOptions<T>, | |
| ): Promise<T> { | |
| try { | |
| return await options.execute(options.hasReferenceImages) | |
| } catch (error) { | |
| if (!options.hasReferenceImages || !options.shouldRetryWithoutImages(error)) { | |
| throw error | |
| } | |
| options.onImageFallback?.(error) | |
| return options.execute(false) | |
| } | |
| } | |