diff --git a/backend/scripts/backfill_usage.py b/backend/scripts/backfill_usage.py index e83a8b73..2c5b11c0 100644 --- a/backend/scripts/backfill_usage.py +++ b/backend/scripts/backfill_usage.py @@ -183,11 +183,16 @@ def backfill_personas(db, dry_run: bool) -> int: for persona in personas: persona_id = str(persona["_id"]) + def _to_str(v): + if isinstance(v, list): + return " ".join(str(i) for i in v if i) + return str(v) if v else "" + # Use background + description as the generation text text = " ".join(filter(None, [ - persona.get("background") or "", - persona.get("description") or "", - persona.get("goals") or "", + _to_str(persona.get("background")), + _to_str(persona.get("description")), + _to_str(persona.get("goals")), ])).strip() if not text: