Skip to content

sweetbean.llm_utils.prompts

demographic(age, gender)

Creates a personalized message using age and gender.

Parameters:

Name Type Description Default
age int

The age of the individual.

required
gender str

The gender of the individual (e.g., 'man', 'woman').

required

Returns:

Name Type Description
str

A formatted message based on the given demographics.

Example

demographic(52, 'woman') 'You are a 52-year-old woman.'

Source code in sweetbean/llm_utils/prompts.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def demographic(age, gender):
    """
    Creates a personalized message using age and gender.

    Parameters:
        age (int): The age of the individual.
        gender (str): The gender of the individual (e.g., 'man', 'woman').

    Returns:
        str: A formatted message based on the given demographics.

    Example:
        >>> demographic(52, 'woman')
        'You are a 52-year-old woman.'

    """

    # Template for generating the message
    template = "You are a {{ age }}-year-old {{ gender }}."

    # Render the template with local variables
    return Template(template).render(age=age, gender=gender)