Explicit language model messages
Supply ordered typed messages, output budget, sampling temperature, finish reason and reported token usage.
// Explicit ordered messages, output budget, and sampling settings.
import aner.llm
let model = llm.client(provider: "ollama", model: "llama3.2:3b",
endpoint: "http://127.0.0.1:11434", timeout_ms: 120000)
let messages = List(
llm.message(role: "system", content: "Explain concepts precisely and concisely."),
llm.message(role: "user", content: "Compare a linked list and a fixed array."))
let answer = model.chat(messages, max_tokens: 256, temperature: 0.2)
print(answer.text())
print(answer.model())
print(answer.finish_reason())
print(answer.input_tokens())
print(answer.output_tokens())
Make it your experiment.
Use Aner 0.0.3 or newer. Save this program as examples/llm_chat.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/llm_chat.aner
aner run examples/llm_chat.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Use Aner 0.0.4 or newer with aner.llm, aner.secrets and VS Code extension 0.1.34 or newer. Checking makes no inference request; running sends the prompt to the explicit provider. Local examples require the named model to be installed or served already. Cloud requests require a configured opaque credential reference and can incur provider charges. See Language model connections and Credentials for supported adapters, HTTPS, timeout, content inspection and storage boundaries.
Client construction and syntax checking send no inference request. Running this program calls its explicit model service. Inspect the returned finish reason and reported usage; unavailable token counts remain unknown and usage does not verify charges.
Read token accounting and provider requirements