ai-tube / src /app /api /generators /clap /unknownObjectToLatentScenes.ts
jbilcke-hf's picture
jbilcke-hf HF staff
upgraded to @aitube/client 0.0.12
f24ad59
raw
history blame
707 Bytes
import { parseStringArray } from "../../parsers/parseStringArray"
import { LatentScene, LatentScenes } from "./types"
/**
* Process a YAML result from the LLM to make sure it is a LatentScenes
*
* @param something
* @returns
*/
export function unknownObjectToLatentScenes(something: any): LatentScenes {
let scenes: LatentScenes = []
if (Array.isArray(something)) {
scenes = something.map(thing => ({
characters: parseStringArray(thing && (thing?.characters || thing?.character)),
locations: parseStringArray(thing && (thing?.locations || thing?.location)),
actions: parseStringArray(thing && (thing?.actions || thing?.action)),
} as LatentScene))
}
return scenes
}