Function v1ToV2

  • Converts a Cards.V1 to a Cards.V2, populating V2 fields with appropriate defaults.

    Example

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

    const v1Card: Cards.V1 = {
    name: 'John',
    description: '{{char}} is a man.',
    personality: 'cruel',
    scenario: '{{char}} hates {{user}}',
    first_mes: 'Hi!',
    mes_example: '',
    }

    const v2CardFromV1: Cards.V2 = {
    spec: 'chara_card_v2',
    spec_version: '2.0',
    data: {
    name: 'John',
    description: '{{char}} is a man.',
    personality: 'cruel',
    scenario: '{{char}} hates {{user}}',
    first_mes: 'Hi!',
    mes_example: '',
    creator_notes: '',
    system_prompt: '',
    post_history_instructions: '',
    alternate_greetings: [],
    character_book: undefined,
    tags: [],
    creator: '',
    character_version: '',
    extensions: {},
    },
    }

    expect(Cards.v1ToV2(v1Card)).toEqual(v2CardFromV1)

    Parameters

    • v1: {
          name: string;
          description: string;
          personality: string;
          scenario: string;
          first_mes: string;
          mes_example: string;
      }
      • name: string
      • description: string
      • personality: string
      • scenario: string
      • first_mes: string
      • mes_example: string

    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