comicbook / src /lib /cleanJson.ts
jbilcke-hf's picture
jbilcke-hf HF staff
up
c32ec0d
raw
history blame
375 Bytes
import { dirtyLLMResponseCleaner } from "./dirtyLLMResponseCleaner"
export function cleanJson(input: string) {
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
}