Blog

Let AI help shape the data your application needs

The Data Model Is an Intent File, Part 3 of 5

Once a data contract becomes something your application can load, it also becomes something your application can help create.

In Part 2, Acme and Globex used different invoice contracts through one C# caller. Acme wanted an invoice number, currency and total. Globex also wanted a purchase order number. The caller received a JsonNode checked against the selected intent file.

Now suppose a customer describes the fields they want from an unfamiliar invoice. AI can propose names and types, the customer can review them, and the application can save the resulting contract. IntentSharp provides schemas supplied at run time, file-based and in-memory catalogs, validators and bounded retries. Your application supplies the setup screen and decides how a proposed contract is accepted.

Choose or create a contract

  • Choose an existing contract. Classify the document, then let the application select an approved invoice, purchase order or delivery-note intent.
  • Create a reusable contract. Let the customer describe the fields they need, review a proposal and save the approved definition. Another customer can use a different definition through the same caller.
  • Explore a new shape. For a research task, ask for flexible JSON observations with TransformAsync<JsonNode> and no output schema. Treat the suggested fields as a proposal. If another component depends on a stable shape, give it a contract before relying on those fields.

From words to a checked shape

A customer says, “Give me the invoice number, total and currency. Include the purchase order number when it appears.” The checked Globex definition from Part 2 shows what one accepted contract could look like:

The checked Globex invoice contractIntent file
name: Globex.Invoice.Extract
version: 1
intent: >
  Extract the invoice number, total, currency, and purchase order number.
  Keep identifiers as written, including leading zeros.
  Return the three-letter currency code. If no purchase order number
  is present, return null for purchaseOrderNumber. Do not invent one.
shape:
  kind: schema
  schema:
    type: object
    properties:
      invoiceNumber: { type: string, minLength: 1 }
      currency: { type: string, enum: [USD, EUR, GBP] }
      total: { type: number, minimum: 0 }
      purchaseOrderNumber: { type: [string, "null"] }
    required: [invoiceNumber, currency, total, purchaseOrderNumber]
    additionalProperties: false
attempts: 2
timeout: PT15S

An invoice number stays text so it keeps leading zeros. Currency has an allowed list. The purchase order property is required, and null means the input had no value for it. Those are business choices a reviewer can see and change. The schema is data: you can store it, compare versions or construct it in code.

Choose what gets checked

Catalog schema shape: A supported schema in a file or an InMemoryIntentCatalog is checked locally against each reply. Add business checks for facts the schema cannot establish, such as whether a supplier exists or an amount matches the source.

Schema passed directly to TransformAsync: The core checks the JSON response envelope and non-null value. Use application validators to enforce constraints you rely on. The runtime-schema example shows checks for required fields and allowed currencies.

Findings can guide a retry within the limits you configure. The following output comes from the tested Part 2 demo. Acme's scripted currency symbol fails before EUR passes, and Globex's scripted reply keeps the purchase order property with a null value:

Output from the scripted replies
Acme.Invoice.Extract: accepted on attempt 2; {"invoiceNumber":"000184","currency":"EUR","total":1860.00}Globex.Invoice.Extract: accepted on attempt 1; {"invoiceNumber":"INV-3307","currency":"USD","total":420.50,"purchaseOrderNumber":null}

The demo checks how the application handles these replies without calling a model. It does not measure live extraction accuracy or guarantee a model will repair a reply. Passing a schema also does not authorize posting an invoice.

Build the consumer for the job

A schema-aware review screen can generate a form or columns from a definition. An accounting export can map approved fields into the destination's contract. A single operation can even return a checked scalar when all you need is one value. Use flexible JSON to explore, then give repeatable work a checked contract. Your application decides which fields it trusts and what happens next.

Next in the series: turn a proposed change into an intent-file edit someone can review.

Try IntentSharp in your .NET project.