Skip to main content

iil-fieldprefill

AI field enrichment — shared prefill orchestration for Django platform apps.

ADR-107: Use iil-fieldprefill as shared AI field enrichment layer.

Installation

pip install iil-fieldprefill                    # Core only
pip install 'iil-fieldprefill[django]'          # With Django HTMX mixin
pip install 'iil-fieldprefill[promptfw]'        # With promptfw templates
pip install 'iil-fieldprefill[all]'             # Everything

Quick Start

from fieldprefill import prefill_field, PrefillResult

result: PrefillResult = prefill_field(
    field_key="geltungsbereich",
    prompt="Beschreibe den Geltungsbereich...",
    action_code="ex_doc_prefill",
    max_tokens=2048,
)
print(result.content)        # Generated text
print(result.tokens_used)    # Input + output tokens
print(result.model)          # e.g. "gpt-4o"
print(result.latency_ms)     # Call duration

Multi-Field Prefill (v0.2.0+)

Enrich multiple fields in a single LLM call with structured JSON response:

from fieldprefill import prefill_fields

result = prefill_fields(
    field_keys=["description", "emotional_arc"],
    prompt="Enrich this chapter with a detailed description and emotional arc.",
    action_code="outline_enrich",
    context={"title": "Chapter 1", "act": "Act I", "beat_phase": "Inciting Incident"},
    scope="writing.outline_enrichment",
)

# Access individual fields from JSON response
node.description = result.get("description")
node.emotional_arc = result.get("emotional_arc")

# Or get full dict
data = result.as_dict()  # {"description": "...", "emotional_arc": "..."}

Cross-Hub Usage

risk-hub — Hazard field enrichment

# Register retrievers in AppConfig.ready()
from fieldprefill.retrievers import register_retriever

@register_retriever("sds")
def get_sds_texts(tenant_id, instance=None):
    from substances.models import Substance
    return [s.summary for s in Substance.objects.filter(tenant_id=tenant_id)]

# Prefill a field using existing document context
result = prefill_field(
    field_key="schutzmassnahmen",
    prompt="Beschreibe die erforderlichen Schutzmaßnahmen...",
    action_code="ex_doc_prefill",
    sources=["sds", "gefaehrdungsbeurteilung"],
    scope="explosionsschutz.ex_doc",
    tenant_id=request.tenant_id,
)

writing-hub — Outline node enrichment

@register_retriever("project_context")
def get_project_context(owner_id, instance=None):
    from apps.authoring.services.project_context_service import ProjectContextService
    ctx = ProjectContextService().get_context(str(instance.pk))
    return [ctx.to_prompt_block()]

result = prefill_fields(
    field_keys=["description", "emotional_arc"],
    prompt="Verfeinere dieses Kapitel mit detaillierter Beschreibung und emotionalem Bogen.",
    action_code="chapter_outline",
    sources=["project_context"],
    context={"title": node.title, "act": node.act, "beat_phase": node.beat_phase},
    scope="writing.outline_enrichment",
    tenant_id=user.pk,
    instance=node.outline_version.project,
)

Django HTMX Mixin

from fieldprefill.django import PrefillViewMixin

class MyEditView(LoginRequiredMixin, PrefillViewMixin, UpdateView):
    prefill_action_code = "ex_doc_prefill"
    prefill_scope = "explosionsschutz.ex_doc"

Architecture

App registers retrievers          fieldprefill orchestrates           aifw calls LLM
─────────────────────────    →    ─────────────────────────    →    ──────────────
@register_retriever("sds")        1. get_context_texts()             sync_completion()
@register_retriever("gbu")        2. build_messages()                completion()
register_system_prompt(...)       3. call_llm_sync/async()
                                  4. PrefillResult

License

MIT

Metadata

Release files for iil-fieldprefill 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iil-fieldprefill 0.2.0
File Size Uploaded Provenance
iil_fieldprefill-0.2.0.tar.gz 14.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for iil-fieldprefill 0.2.0
File Interpreter ABI Platform
iil_fieldprefill-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.9 kB

Release files / iil_fieldprefill-0.2.0.tar.gz

Download URL iil_fieldprefill-0.2.0.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
188ba8cc9a0ec746dc77f8c2d8acbb61df4977bc86d91f2420f38012d3f3d7b3
BLAKE2b-256 checksum
How to use checksums
b06fd39c4182fdd3a3fc08fb7873d698fbce8a188a154cc5f73cfaace1eacd31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 8, 2026.

Transparency log

Release files / iil_fieldprefill-0.2.0-py3-none-any.whl

Download URL iil_fieldprefill-0.2.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
916a47b7e78a2e655abbb44c2ee4ae6e6c966ffefd68c189517c41c053ba86d3
BLAKE2b-256 checksum
How to use checksums
bc4edee04745af6e50cc5d8a9f718d130909e3b43b4362b618f31ce13436c100
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 8, 2026.

Transparency log

Security for iil-fieldprefill 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for iil_fieldprefill-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page