Skip to content

{{ 🧩 }} Add custom jinja filter for shuffling elements of your prompt #88

@johnnygreco

Description

@johnnygreco

doing something like below with a shuffle filter (which doesn't exist in standard Jinja, but can be implemented) would be helpful to drive diversity not just in Personas, but basically all use-cases we have today:

{% set items = [
    ('Name', first_name ~ ' ' ~ (middle_name if middle_name else '') ~ ' ' ~ last_name),
    ('Sex', sex),
    ('Age', age|string),
    ('Ethnic background', ethnic_background),
    ('Marital status', marital_status),
    ('Occupation', occupation),
    ('Location', city ~ ', ' ~ state ~ ', ' ~ county)
] %}

Based on a person with the following profile:
{% for label, value in items|shuffle %}
{% if value %}{{ label }}: {{ value }}
{% endfor %}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions