Sub topic 2
What you can build: a map of application types
This chapter assumes you know basic Python, JSON, and HTTP APIs, and have used a chatbot. It gives you a map of the main application patterns. Later chapters cover each one in detail.
One model, a few patterns
Every LLM application sends text to a model and uses the text that comes back. The patterns differ in what you put into the prompt and what your code does with the reply.
| Pattern | Input to the model | What your code does with the output | Typical example |
|---|---|---|---|
| Text transformation | The user's text plus instructions | Shows it to a person | Summarize a meeting, translate a page |
| Classification and extraction | Text plus allowed labels or fields | Validates it, then stores it | Route support tickets, read invoices |
| Conversational assistant | The conversation so far | Shows the reply, keeps history | Help-desk chat |
| Retrieval-augmented generation (RAG) | The question plus passages found in your documents | Shows an answer with sources | Q&A over a policy handbook |
| Tool use | The request plus tool descriptions | Runs the requested function, returns the result | "What is the weather in Oslo?" |
| Agent | A goal plus tools | Loops: call a tool, read the result, decide the next step | Research or booking workflows |
| Code assistance | Code plus a request | Shows a suggestion or runs checks | Review a diff |
| Multimodal | Images, audio, or documents | Same as above | Read a scanned receipt |
Choosing by what the model lacks
Start from what the model cannot do alone. It knows nothing about your private data, it cannot act in the world, and its output is free text. Each gap points to a pattern.
Patterns also combine. A support assistant might use RAG to find policy text, a tool to look up an order, and a classifier to route the conversation.
Start with the simplest pattern
Complexity grows down the table. Each step adds components that can fail: a vector index for RAG, a loop for agents. Pick the lowest row that solves the problem. A single prompt with a validated reply is often enough:
LABELS = ["billing", "bug", "feature_request", "other"]
def classify(ticket: str, complete) -> str:
prompt = (
"Classify the support ticket into exactly one label from: "
+ ", ".join(LABELS)
+ ".\nReply with the label only.\n\nTicket: " + ticket
)
answer = complete(prompt).strip().lower()
return answer if answer in LABELS else "other"Here complete is any function that sends a prompt to your model API and returns its text. The final line is the important part. Your code checks the reply and falls back to a safe label.
Common mistakes
- Building an agent when a fixed sequence of two prompts would do.
- Expecting the model to know facts from your private documents without retrieval.
- Using model output directly in code without validating it.
- Treating "chatbot" as the only shape. Many useful features have no chat window.
Exercise
A tool must read uploaded contracts, pull out the party names and end date, and save them to a database. Which pattern fits, and what must your code do before saving?
Show answer
Extraction, possibly with a multimodal step if the contracts are scans. Your code must parse the model's output (for example as JSON) and validate that the fields exist and have the right types before saving. Reject or retry on failure.