Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inheritance of character from parent using extends key #2159

Merged
merged 2 commits into from
Jan 11, 2025

Conversation

ShreyGanatra
Copy link
Contributor

@ShreyGanatra ShreyGanatra commented Jan 11, 2025

Risks

Low

Background

What does this PR do?

This PR introduces an inheritance system for character files, allowing for more organized and maintainable character configurations.

Key Features:

  1. Inheritance Mechanism:

    • Character files can now include an extends field, which is an array of parent character files.
    • Example:
      {
        "extends": ["parent1.character.json", "parent2.character.json"]
      }
    • When a child character file is loaded, it first loads all information from its specified parent character files.
  2. Improved Organization:

    • This system allows for better organization of character files by enabling shared configurations across multiple characters.
    • Common traits and settings can be defined in parent files, reducing redundancy and making updates easier.
  3. Ease of Maintenance:

    • Updates to parent character files automatically propagate to all child character files, ensuring consistency and reducing the need for manual updates.

Benefits:

  • Modularity: Break down character configurations into reusable components.
  • Scalability: Easily manage and scale character configurations as the project grows.
  • Consistency: Ensure consistent settings and traits across multiple characters with minimal effort.

This PR significantly enhances the flexibility and maintainability of character files, making it easier to manage complex configurations and updates.

What kind of change is this?

Features

Documentation changes needed?

My changes require a change to the project documentation.
Change the character file documentation

Testing

  1. Define Parent Character Files:

    • Create character files with common settings and traits that you want to share across multiple characters.
    • Example parent1.character.json:
      {
        "name": "Parent Character 1",
        "bio": "This is a parent character.",
        "settings": {
          "voice": { "model": "en_US-male-medium" }
        }
      }
  2. Create Child Character Files:

    • In the child character files, use the extends field to specify the parent character files.
    • Example child.character.json:
      {
        "extends": ["parent1.character.json"],
        "name": "Child Character",
        "bio": "This is a child character inheriting from Parent Character 1."
      }
  3. Run the Project:

    • Use the command pnpm start --character="child.character.json" to load the character files. The system will automatically handle the inheritance and load the necessary information from the parent files.

Discord username

@thegreatsvg

Copy link
Collaborator

@monilpat monilpat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inheritance via Composition is key, as another follow up on this adding an implements for an interface would be very useful as well :)

@monilpat
Copy link
Collaborator

Great work :)

@monilpat monilpat merged commit ea154a0 into elizaOS:develop Jan 11, 2025
3 checks passed
0xpi-ai pushed a commit to 0xpi-ai/NayariAI that referenced this pull request Jan 15, 2025
inheritance of character from parent using extends key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants