How can I refer to an user defined Enum type in a Jinja template?
- User
How can I refer to an user defined Enum type in a Jinja template?
Assistant
In Jinja, you can refer to a user-defined Enum type just like you would refer to any other variable. Assuming that you have passed an instance of the Enum to your template context, you can access its members using dot notation.
For example, let's say you have the following Enum defined in your Python code:
pythonfrom enum import Enum class Color(Enum): RED = 'red' GREEN = 'green' BLUE = 'blue'You can pass an instance of this Enum to your Jinja template context like this:
python
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.