// Requires a compatible installed runtime with the selected native capabilities.
// Replace the GGUF path and budgets for the actual machine. Budgets use MiB.
// Auto selects a supported local device; CPU-only builds use host RAM.
import aner.llm
import aner.api

print(llm.devices())
print(llm.plan("models/local-instruct-q4.gguf", context: 2048,
    device: "auto", kv_cache_type: "f16", flash_attention: "auto",
    gpu_budget_mib: 7168, ram_budget_mib: 24576, reserve_mib: 512))

// Load recomputes admission against the current machine and validates allocation.
let serving = llm.load_fitted("models/local-instruct-q4.gguf", context: 2048,
    device: "auto", kv_cache_type: "f16", flash_attention: "auto",
    gpu_budget_mib: 7168, ram_budget_mib: 24576, reserve_mib: 512)
let warmup = serving.generate("Say hello.", max_tokens: 1)
print(warmup.text())
print(serving.load_summary())
print(serving.memory_summary())

let app = api.app("Aner fitted chat").llm(path: "/chat", model: serving)
    .bind(host: "127.0.0.1", port: 11435)
    .limits(max_rows: 64, timeout_ms: 120000)
    .output_limit(max_tokens: 128)
app.serve()
serving.close()
