VariableModality
Astr enum defining the modality types for prompt variables.
Overview
VariableModality specifies what kind of content a PromptVariable represents. Each modality determines how the variable value is interpreted and rendered when injected into a prompt.
Import
Type Definition
VariableModality is a str enum with the following values:
| Value | Enum Member | Description |
|---|---|---|
"text" | VariableModality.TEXT | Plain text content. The most common modality for string substitution in prompts. |
"image" | VariableModality.IMAGE | Image content, provided as a URL or base64-encoded string. |
"pdf" | VariableModality.PDF | PDF document content for document-understanding workflows. |
"api" | VariableModality.API | External API data source. The variable value is fetched from an API at runtime. |
"prompt" | VariableModality.PROMPT | Nested prompt reference. Allows composing prompts from other prompts. |
Usage
Creating variables with different modalities
String comparison
BecauseVariableModality is a str enum, you can compare it directly with plain strings:
Branching on modality
JSON Representation
In JSON payloads, modality values are plain strings:Related
- PromptVariable — uses
VariableModalityto define variable types