LegalForm Filling & Marketplace

Form Filling & Marketplace

Generate filled Nepali government and legal forms as PDFs through chat

Baudhik AI includes a form-filling pipeline that lets you generate filled Nepali government and legal forms as downloadable PDFs, directly through chat.

How it works

The pipeline uses two agent tools:

  1. Search Forms (search_forms) — searches registered forms by keyword, scoped to the agent's allowed form groups
  2. Fill Form (fill_form) — validates your data against the form's schema, renders a PDF, stores it, and returns a download link

From the chat UI

When you ask the agent to fill a form, it searches for matching forms, asks you for the required details, validates the data, and generates a PDF. The filled form appears as a downloadable attachment in the chat.

From the Marketplace

The Marketplace is a consumer-facing page where you can browse available forms and launch a chat session pre-anchored to a specific form. When you pick a form from the Marketplace, the agent skips the search step and goes straight to filling that form.

Marketplace access is gated by a permission scope. Contact your administrator if you do not see the Marketplace page.

For administrators

Registering forms

Admins manage forms through the admin panel at Admin → Forms:

  • Slug — a unique identifier for the form
  • Title and description — shown to users
  • JSON Schema — defines the form fields, types, and validation rules
  • Jinja2 template — the PDF layout template
  • AI context (optional) — domain and instructions that guide the LLM when filling fields
  • Form groups — scopes which agents can search for this form

AI-Assist field fill

Admins can mark specific form fields as x-ai-assisted: true in the JSON Schema. When a user provides some known fields, the AI-Assist endpoint fills the marked fields automatically:

POST /api/ai-assist/field-fill

The endpoint:

  • Takes a source_slug, known_fields, and the form context
  • Returns {filled, confidence, unfillable} per field
  • Confidence levels: high (unambiguous), medium (reasonably inferred), low (uncertain)

Sensitive fields marked x-sensitive are masked as [provided] in the LLM prompt — the actual value is never sent to the model. The endpoint also enforces limits: max 20 fields, 10KB payload, 500 chars per value.

Session anchoring

When a form is launched from the Marketplace, the chat session is anchored to that specific form. The agent skips search_forms and calls fill_form directly, streamlining the experience for end users.