Add Field Definitions
Adds new fields to the global BASE_FIELD_DEFINITIONS registry in prompture/field_definitions.py.
Before Starting
Ask the user for each field:
- Field name — lowercase, underscore-separated (e.g.
linkedin_url, blood_type)
- Category — Person, Contact, Professional, Financial, Location, Education, Demographic, Social Media, Task Management, or a new one
- Type —
str, int, float, bool, list, dict
- Description — what this field represents
- Instructions — how the LLM should extract or compute the value
- Default — type-appropriate:
"" for str, 0 for int, 0.0 for float, [] for list, False for bool
- Nullable —
True if the field can legitimately be absent
- Enum values (optional) — list of allowed string values
Field Structure
"field_name": {
"type": str,
"description": "What this field represents.",
"instructions": "How the LLM should extract or compute this value.",
"default": "",
"nullable": False,
},
Optional keys
"enum": ["low", "medium", "high"]
- Template variables in
instructions: {{current_year}}, {{current_date}}, {{current_datetime}}, {{current_month}}, {{current_day}}, {{current_weekday}}, {{current_iso_week}}
Steps
1. Edit prompture/field_definitions.py
Add fields to BASE_FIELD_DEFINITIONS under the right category comment. If the category is new, add a comment header:
# ── Medical Fields ──────────────────────────────────
Alphabetical order within each category.
2. Verify
python -c "from prompture.field_definitions import get_field_definition; print(get_field_definition('field_name'))"
pytest tests/test_field_definitions.py -x -q
1---2name: add-field3description: Add predefined field definitions to the Prompture field registry. Handles field structure, categories, template variables, enum support, and thread-safe registration. Use when adding reusable extraction fields.4---56# Add Field Definitions78Adds new fields to the global `BASE_FIELD_DEFINITIONS` registry in `prompture/field_definitions.py`.910## Before Starting1112Ask the user for each field:13- **Field name** — lowercase, underscore-separated (e.g. `linkedin_url`, `blood_type`)14- **Category** — Person, Contact, Professional, Financial, Location, Education, Demographic, Social Media, Task Management, or a new one15- **Type** — `str`, `int`, `float`, `bool`, `list`, `dict`16- **Description** — what this field represents17- **Instructions** — how the LLM should extract or compute the value18- **Default** — type-appropriate: `""` for str, `0` for int, `0.0` for float, `[]` for list, `False` for bool19- **Nullable** — `True` if the field can legitimately be absent20- **Enum values** (optional) — list of allowed string values2122## Field Structure2324```python25"field_name": {26 "type": str,27 "description": "What this field represents.",28 "instructions": "How the LLM should extract or compute this value.",29 "default": "",30 "nullable": False,31},32```3334### Optional keys3536- `"enum"`: `["low", "medium", "high"]`37- Template variables in `instructions`: `{{current_year}}`, `{{current_date}}`, `{{current_datetime}}`, `{{current_month}}`, `{{current_day}}`, `{{current_weekday}}`, `{{current_iso_week}}`3839## Steps4041### 1. Edit `prompture/field_definitions.py`4243Add fields to `BASE_FIELD_DEFINITIONS` under the right category comment. If the category is new, add a comment header:4445```python46 # ── Medical Fields ──────────────────────────────────47```4849Alphabetical order within each category.5051### 2. Verify5253```bash54python -c "from prompture.field_definitions import get_field_definition; print(get_field_definition('field_name'))"55pytest tests/test_field_definitions.py -x -q56```