Compress character helper fact output
This commit is contained in:
@@ -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`
|
- 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`
|
- Outputs: `image1`, `image2`, `character_text`
|
||||||
- Passes both images through unchanged and builds a character reference string such as `<Picture 2> and <Picture 3> reference the same character who is called Dave.`
|
- Passes both images through unchanged and builds a character reference string such as `<Picture 2> and <Picture 3> 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`
|
- `Dumas JSON String to Object`
|
||||||
- Input: `json_string`
|
- Input: `json_string`
|
||||||
|
|||||||
+12
-17
@@ -360,33 +360,28 @@ def _build_character_helper_text(
|
|||||||
f"<Picture {secondary_picture}> is a frontal facial reference for {character_label}.",
|
f"<Picture {secondary_picture}> is a frontal facial reference for {character_label}.",
|
||||||
]
|
]
|
||||||
|
|
||||||
if character_id:
|
fact_fragments = []
|
||||||
lines.append(f'The character ID string is "{character_id}".')
|
|
||||||
|
|
||||||
if alias:
|
if alias:
|
||||||
lines.append(f"{character_label} is also known as {alias}.")
|
fact_fragments.append(f"is also known as {alias}")
|
||||||
|
|
||||||
if gender:
|
if gender:
|
||||||
lines.append(f"{character_label} is {gender}.")
|
fact_fragments.append(f"is {gender}")
|
||||||
|
|
||||||
if age_value is not None:
|
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:
|
if nationality:
|
||||||
lines.append(f"{character_label} is {nationality}.")
|
fact_fragments.append(f"is {nationality}")
|
||||||
|
|
||||||
if occupation:
|
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)
|
height_text = _format_height_text(height_feet, height_inches)
|
||||||
if height_text:
|
if height_text:
|
||||||
lines.append(f"{character_label} is {height_text} tall.")
|
fact_fragments.append(f"is {height_text} tall")
|
||||||
|
|
||||||
if accent:
|
if accent:
|
||||||
lines.append(
|
fact_fragments.append(
|
||||||
f"{character_label} speaks in {_indefinite_article(accent)} {accent} accent."
|
f"speaks in {_indefinite_article(accent)} {accent} accent"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if fact_fragments:
|
||||||
|
lines.append(f"{character_label} {', '.join(fact_fragments)}.")
|
||||||
|
|
||||||
if general:
|
if general:
|
||||||
lines.append(general)
|
lines.append(general)
|
||||||
|
|
||||||
|
|||||||
@@ -270,14 +270,7 @@ class DumasImageNodeTests(unittest.TestCase):
|
|||||||
"<Picture 2> and <Picture 3> reference the same character who is called Dave.\n"
|
"<Picture 2> and <Picture 3> reference the same character who is called Dave.\n"
|
||||||
"<Picture 2> is the primary full-body reference for Dave.\n"
|
"<Picture 2> is the primary full-body reference for Dave.\n"
|
||||||
"<Picture 3> is a frontal facial reference for Dave.\n"
|
"<Picture 3> is a frontal facial reference for Dave.\n"
|
||||||
'The character ID string is "char_dave".\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"
|
||||||
"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"
|
|
||||||
"wears a long grey coat."
|
"wears a long grey coat."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user