- parseToV2(data): {
spec: "chara_card_v2";
spec_version: string;
data: {
name: string;
description: string;
personality: string;
scenario: string;
first_mes: string;
mes_example: string;
creator_notes: string;
system_prompt: string;
post_history_instructions: string;
alternate_greetings: string[];
character_book?: { entries: { keys: string[]; content: string; extensions: Record<string, any>; enabled: boolean; insertion_order: number; case_sensitive?: boolean | undefined; name?: string | undefined; ... 6 more ...; position?: "before_char" | ... 1 more ... | undefined; }[]; ... 5 more ...; recursive_scanning?: boolean | undefin...;
tags: string[];
creator: string;
character_version: string;
extensions: Record<string, any>;
};
}
-
Returns {
spec: "chara_card_v2";
spec_version: string;
data: {
name: string;
description: string;
personality: string;
scenario: string;
first_mes: string;
mes_example: string;
creator_notes: string;
system_prompt: string;
post_history_instructions: string;
alternate_greetings: string[];
character_book?: { entries: { keys: string[]; content: string; extensions: Record<string, any>; enabled: boolean; insertion_order: number; case_sensitive?: boolean | undefined; name?: string | undefined; ... 6 more ...; position?: "before_char" | ... 1 more ... | undefined; }[]; ... 5 more ...; recursive_scanning?: boolean | undefin...;
tags: string[];
creator: string;
character_version: string;
extensions: Record<string, any>;
};
}
-
spec: "chara_card_v2"
-
spec_version: string
-
data: {
name: string;
description: string;
personality: string;
scenario: string;
first_mes: string;
mes_example: string;
creator_notes: string;
system_prompt: string;
post_history_instructions: string;
alternate_greetings: string[];
character_book?: { entries: { keys: string[]; content: string; extensions: Record<string, any>; enabled: boolean; insertion_order: number; case_sensitive?: boolean | undefined; name?: string | undefined; ... 6 more ...; position?: "before_char" | ... 1 more ... | undefined; }[]; ... 5 more ...; recursive_scanning?: boolean | undefin...;
tags: string[];
creator: string;
character_version: string;
extensions: Record<string, any>;
}
-
name: string
-
description: string
-
personality: string
-
scenario: string
-
first_mes: string
-
mes_example: string
-
creator_notes: string
-
system_prompt: string
-
post_history_instructions: string
-
alternate_greetings: string[]
-
Optional
character_book?: { entries: { keys: string[]; content: string; extensions: Record<string, any>; enabled: boolean; insertion_order: number; case_sensitive?: boolean | undefined; name?: string | undefined; ... 6 more ...; position?: "before_char" | ... 1 more ... | undefined; }[]; ... 5 more ...; recursive_scanning?: boolean | undefin...
-
tags: string[]
-
creator: string
-
character_version: string
-
extensions: Record<string, any>
Takes unknown data, and returns a
Cards.V2
.If the input is a V1 card, it will be converted to V2. If the input is neither V2 nor V1, it will throw a ZodError.
For an alternative which doesn't throw on failure, see safeParseToV2
Example