Skip to content

8.3.1 Application Development Roadmap: API, Tools, State

LLM application development is not just an input box plus a model API. A real feature validates input, calls models, uses tools, keeps state, parses output, logs errors, and gives users a recoverable experience.

LLM application development chapter relationship diagram

LLM application development learning order diagram

LLM application capability loop diagram

The chapter upgrades one model call into a maintainable application loop: input, prompt/context, model, optional tool, validation, output, feedback.

Function Calling means the model proposes structured action arguments, but your application must validate and dispatch them.

model_output = {
"tool": "search_docs",
"arguments": {"query": "RAG citations"},
}
allowed_tools = {
"search_docs": {"required": ["query"]},
"create_ticket": {"required": ["title", "priority"]},
}
tool = model_output["tool"]
required = allowed_tools[tool]["required"]
validation_ok = all(name in model_output["arguments"] for name in required)
print("validation_ok:", validation_ok)
print("dispatch:", tool if validation_ok else "block")

Expected output:

Terminal window
validation_ok: True
dispatch: search_docs

Never execute tool calls directly from model text. Validate tool name, argument schema, permission, and failure path.

StepReadPractice Output
1LLM API practiceWrite a robust call wrapper with timeout and error handling
2Framework basicsSplit prompt, model, tool, memory, retrieval, and parser roles
3Function CallingValidate structured tool arguments before dispatch
4Hugging Face ecosystemKnow when hosted, local, or browser-side models fit
5Dialogue systemsStore session state, slots, memory, and user feedback
6Document and template appsTurn parsing, extraction, and generation into modules

Keep this page’s proof of learning as a small evidence card:

Request
input, state, tools/context, and expected output contract
Validated Output
parser/schema or business-rule check result
Trace
model call, tool/function call, document parse, or dialogue state
Failure Check
invalid format, missing field, stale state, or wrong tool
Next Action
prompt, schema, state, API, or parsing improvement

You pass this chapter when you can build a small assistant loop that handles one API call, one optional tool call, one structured output, and one error path.

The exit mini project is a course Q&A and study-planning assistant that classifies the user request, optionally retrieves knowledge, returns structured suggestions, and logs feedback.

Check reasoning and explanation
  1. A passing answer traces the full path from query to chunks, retrieval scores, cited evidence, answer, and fallback behavior.
  2. The evidence should include retrieved passages, source metadata, a cited answer, and at least one empty-retrieval or wrong-retrieval case.
  3. A good self-check explains whether a failure came from chunking, retrieval, ranking, prompt assembly, missing sources, or unsupported generation.