Skip to main content

Crate fim_engine

Crate fim_engine 

Source
Expand description

fim-engine — embedded fill-in-the-middle code completion.

A self-contained local code-completion engine: it downloads a small quantized qwen2.5-coder model on first use, caches it, and runs inference in-process via candle — no external daemon, no API key, no network after the one-time download.

Shared by mnml + tmnl. Typical use:

use fim_engine::{FimEngine, ModelChoice};

// Blocking — do this on a worker thread.
let cache = fim_engine::default_cache_dir();
let mut engine = FimEngine::load(&cache, ModelChoice::Qwen1_5B, &|p| {
    eprintln!("{}: {}/{:?}", p.label, p.received, p.total);
})?;
let completion = engine.complete("fn add(a: i32, b: i32) -> i32 {\n    ", "\n}", 64)?;

Structs§

DownloadProgress
Progress callback payload — emitted periodically during a download so the host can paint a progress bar.
FimEngine
A loaded local FIM completion engine. Holds the model in memory; keep one alive and call FimEngine::complete repeatedly.
ModelPaths
Resolved on-disk paths to the two model files.

Enums§

ModelChoice
Which qwen2.5-coder size to run. 1.5B is the fast default; 3B is noticeably smarter at multi-line completion but ~2x slower + a bigger download. (Instruct GGUFs — the base GGUF repos are gated; instruct retains FIM capability.)

Functions§

default_cache_dir
The canonical, host-agnostic model cache directory — every consumer (mnml, tmnl, …) should pass this to FimEngine::load so the ~1 GB download is shared, not duplicated per app.
is_model_cached
True when both model files for choice are already cached.