Spaces:
Sleeping
Sleeping
Download src/lib/cleanJson.ts from Joshleeave/AIComicFactory: direct link, hf CLI and curl.
- Browser
- Download file 444 Bytes
-
https://huggingface.co/spaces/Joshleeave/AIComicFactory/resolve/main/src/lib/cleanJson.ts
- Command line
-
hf download hf://spaces/Joshleeave/AIComicFactory/src/lib/cleanJson.ts
-
curl -L -o cleanJson.ts https://huggingface.co/spaces/Joshleeave/AIComicFactory/resolve/main/src/lib/cleanJson.ts
444 Bytes
| import { dirtyLLMResponseCleaner } from "./dirtyLLMResponseCleaner" | |
| export function cleanJson(input: string) { | |
| if (input.includes('```')) { | |
| input = input.split('```')[0] | |
| } | |
| let tmp = dirtyLLMResponseCleaner(input) | |
| // we only keep what's after the first [ | |
| tmp = `[${tmp.split("[").pop() || ""}` | |
| // and before the first ] | |
| tmp = `${tmp.split("]").shift() || ""}]` | |
| tmp = dirtyLLMResponseCleaner(tmp) | |
| return tmp | |
| } |