diff --git a/README.md b/README.md index 36f71d0..dbd3e5c 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ - Inputs: `image1`, `image2`, `image1_picture_id`, `image2_picture_id`, `character_id`, `name`, `alias`, `gender`, `age`, `nationality`, `occupation`, `height_feet`, `height_inches`, `accent`, `general` - Outputs: `image1`, `image2`, `character_text` - Passes both images through unchanged and builds a character reference string such as ` and reference the same character who is called Dave.` - - Appends optional sentences for non-visual facts such as ID, alias, gender, age, nationality, occupation, height, accent, and freeform notes only when those fields are valid and filled in. + - Collapses optional non-visual facts such as alias, gender, age, nationality, occupation, height, and accent into one comma-separated sentence, then ends with the freeform note as the final sentence when provided. - `Dumas JSON String to Object` - Input: `json_string` diff --git a/dumas_image_nodes.py b/dumas_image_nodes.py index 4de0a70..2183e0b 100644 --- a/dumas_image_nodes.py +++ b/dumas_image_nodes.py @@ -360,33 +360,28 @@ def _build_character_helper_text( f" is a frontal facial reference for {character_label}.", ] - if character_id: - lines.append(f'The character ID string is "{character_id}".') - + fact_fragments = [] if alias: - lines.append(f"{character_label} is also known as {alias}.") - + fact_fragments.append(f"is also known as {alias}") if gender: - lines.append(f"{character_label} is {gender}.") - + fact_fragments.append(f"is {gender}") if age_value is not None: - lines.append(f"{character_label} is {age_value} years old.") - + fact_fragments.append(f"is {age_value} years old") if nationality: - lines.append(f"{character_label} is {nationality}.") - + fact_fragments.append(f"is {nationality}") if occupation: - lines.append(f"{character_label} works as {occupation}.") - + fact_fragments.append(f"works as {occupation}") height_text = _format_height_text(height_feet, height_inches) if height_text: - lines.append(f"{character_label} is {height_text} tall.") - + fact_fragments.append(f"is {height_text} tall") if accent: - lines.append( - f"{character_label} speaks in {_indefinite_article(accent)} {accent} accent." + fact_fragments.append( + f"speaks in {_indefinite_article(accent)} {accent} accent" ) + if fact_fragments: + lines.append(f"{character_label} {', '.join(fact_fragments)}.") + if general: lines.append(general) diff --git a/tests/test_dumas_image_nodes.py b/tests/test_dumas_image_nodes.py index c263d91..bc4135b 100644 --- a/tests/test_dumas_image_nodes.py +++ b/tests/test_dumas_image_nodes.py @@ -270,14 +270,7 @@ class DumasImageNodeTests(unittest.TestCase): " and reference the same character who is called Dave.\n" " is the primary full-body reference for Dave.\n" " is a frontal facial reference for Dave.\n" - 'The character ID string is "char_dave".\n' - "Dave is also known as The Locksmith.\n" - "Dave is male.\n" - "Dave is 41 years old.\n" - "Dave is English.\n" - "Dave works as a detective.\n" - "Dave is 6 feet 2 inches tall.\n" - "Dave speaks in an English accent.\n" + "Dave is also known as The Locksmith, is male, is 41 years old, is English, works as a detective, is 6 feet 2 inches tall, speaks in an English accent.\n" "wears a long grey coat." ), )