Function parseToV2

  • 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

    import * as Cards from 'character-card-utils'

    Cards.parseToV2(validV2Card) //=> return type Cards.V2
    Cards.parseToV2(validV1Card) //=> return type Cards.V2
    Cards.parseToV2(invalidCard) //=> throws ZodError

    Parameters

    • data: unknown

    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"

      Identifier for the Character Card spec used. Can only be 'chara_card_v2'.

    • spec_version: string

      Non-breaking minor spec version. Expected to be '2.0' at this time.

    • 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>

Generated using TypeDoc