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

Allow loading of PNG "Character Card" characters #5114

Open
wants to merge 29 commits into
base: dev
Choose a base branch
from

Conversation

TheInvisibleMage
Copy link
Contributor

@TheInvisibleMage TheInvisibleMage commented Dec 28, 2023

Description:

  • Adds the ability to load in Character Cards in ".png" format.
  • Modifies context building to be easily expanded to more character formats.
  • Deduplicates sections when loading a character.

Notes:

  • When saving a character, they still always save in YAML, in the text-generation-web-ui's native format (Eg. Only "name", "greeting", and "context". This is also true in Main at the moment, but wanted to call it out regardless; adding the ability to save into whatever format is desired (or at least the format the character is currently in) would be handy.
  • This PR also adds deduplication when a character is "multi-format", such as a character with both the "personality" and "description" keys. I'm not familiar with every variation of the formats, so it's possible there's valid use cases where these would differ. Please let me know if there are tweaks required to properly convert a format.
    • Note that this deduplication applies only to "complete" duplicates, or duplicates where one string is entirely within another. For example, a character with a "personality" of "This is an AI." and a "description" of "This is an AI. They are super cool", would result in only the latter being used, but if the "personality" was instead "This is an AI. They are super lame", then both would be applied (resulting in "This is an AI. They are super lame. This is an AI. They are super cool."). A bit less than ideal, but should be good enough for now, especially considering that this is kind of an edge case.
    • Another option to consider; currently the above deduplication only works between similar "categories" of context sections. Eg. Personality/description/char_persona are all the same category. Should we consider deduping across categories too, so if, say, a scenario had duplicate text to a personality, it would be removed?
  • The "get_available_characters" method in "utils.py" has been modified to allow pngs to be collected, but has not been modified to handle multiple instances of the same character with different formats (eg. "Ai.json" and "Ai.png"). I believe it seems to select which one to use based on alphabetical order, but not certain. I'd like to get others opinions on whether we should add the extension to the name (so all variations of a given char are displayed), add a format selector dropdown, or some other solution.

Credits:

  • Shoutout to Mindus1's TAIConvert, which showed me how to extract the character info from images.

Checklist:

oobabooga and others added 29 commits December 14, 2023 22:39
@oobabooga oobabooga deleted the branch oobabooga:dev February 17, 2024 21:53
@oobabooga oobabooga closed this Feb 17, 2024
@oobabooga oobabooga reopened this Feb 17, 2024
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