AI MOOC
✦ Grow togetherInvite 3 friends, earn 1 month of membership · Up to 12 monthsInvite friends →

Library / My reading notes

Define the contract before choosing a model

Turn “summarize this text” into a verifiable interface.

Back to course plan: Design a bounded AI text assistant

Chapter 1 / 3 · Read and take notes

Turn “summarize this text” into a verifiable interface.

Understand the method

An application does more than send text to a model. Users need defined inputs, outputs and recovery from failure. Our assistant summarizes provided public text without browsing for facts. Limit input to 20–2000 characters and return a summary with caveats. The model may change while the business contract remains consistent.

The browser sends necessary text; the server keeps credentials. Check identity, input length and quota before calling a model. Never put credentials in frontend code or screenshots. Treat model output as a draft until structural and business validation succeeds.

  1. 1Browser input
  2. 2Server checks
  3. 3Model draft
  4. 4Validate and show

Included material

Public fictional text: Three report templates were tested this week. The team chose template B for another trial. Time savings have not been measured. The final approach will be confirmed after next week’s review.

Work through the steps

  1. Specify input type, size, purpose and prohibited additions.
  2. Define output fields and bounds and create one valid object.
  3. Map browser, server, model and validation in order.

Worked example

POST /api/text-summary
Input: {"text":"public source text, 20–2000 characters"}
Output: {"summary":"1–300 characters", "caveats":["0–5 items"]}
Errors: 400 invalid input; 429 quota; 502 invalid output; 503 unavailable
No browser-side API key. No automatic publication.

Your exercise

Manually write a valid summary object and preserve “not measured” and “to confirm.” This is a validation fixture, not evidence of a live model call.

Check before delivery

  • Another developer can understand the input, output and error states.
  • A template trial is not presented as measured efficiency gain.
Finish the exercise, then view the reference

Example summary: “Template B proceeds to another trial.” Caveats: “Time savings not measured” and “Final decision pending next week’s review.” Add no invented improvement rate or approval.

An original course with teaching exercises. Reading records, practice outcomes and independent certification are distinct.

References and further reading

The lessons are original. The following sources are provided under their respective permissions.

Course

Generative AI for Beginners

Microsoft · en/zh

MIT

License checked. This entry links to the original; the book text is not mirrored.

License checked: 2026-10-16 · Pinned d45da912
Course

Generative AI with JavaScript

Microsoft · en/zh

MIT

License checked. This entry links to the original; the book text is not mirrored.

License checked: 2026-10-16 · Pinned 03e41953
Book

Self-LLM: open LLM deployment guide

Datawhale · en/zh

Apache-2.0

License checked. This entry links to the original; the book text is not mirrored.

License checked: 2026-10-16 · Pinned e0fe14a3