Chapter 8½: inside llm/src

  1. lib.rs opens with the limits (MAX_CALLS, MAX_OPTIONS, SCORE_LEVELS, MAX_TOKENS), then SYSTEM, the whole system prompt, and tools(), the three tool definitions. Read those two first: they are the behaviour. Then settled and settled_system (narrowing the tools to what the rules asked for), takes, request, and finally the reading side: Draft, ToolCall, Usage, Reply and parse.
  2. models.rs is the price list: every candidate under Haiku's price, cheapest first, each with its price in neurons per million tokens in and out, from Cloudflare's pricing page on 2026-10-02; and Model::neurons and Model::worst_case_neurons.
  3. tests.rs feeds parse real replies, including the double-encoded arguments one model sent, and checks request gives only the tools asked for.

Try it. cargo test -p llm.

FileWhat
lib.rsThe prompt, the tools, request, takes and parse.
models.rsThe candidate models and their prices.
tests.rsReplies parsed and requests built.

← Previous: Chapter 8, llm/ · Up: llm · Next: Chapter 9, archive/ →