Skip to main content

Crate xybrid_llama

Crate xybrid_llama 

Source
Expand description

Safe Rust wrappers over [llama-cpp-sys].

Owns the FFI boundary for llama.cpp: RAII handles, typed errors, the streaming trampoline. Downstream code (the xybrid-core adapter, Phase 2’s consumers, and any future backend that wants llama-cpp without the xybrid-core surface) only touches the safe types in this crate.

§Activation

The real implementation lives behind the bindings cargo feature. A default build — cargo build -p xybrid-llama — compiles this crate to an empty shell on every target, which keeps cargo clippy --workspace on Linux CI runners green even without a C++ toolchain.

§Public surface

  • LlamaModel — owning handle to a loaded GGUF model
  • LlamaContext — owning handle to a llama context, with KV-cache manipulation methods
  • [StreamingCallback] — closure type alias for streaming generation
  • [generate_streaming] / [generate_with_stops] — the autoregressive loops, including the prefix-reuse n_past_in knob
  • set_verbosity / get_verbosity — llama.cpp log-level control
  • LlamaError / LlamaResult — error surface

Zero unsafe appears on the public surface. Every unsafe block lives in the [mod@ffi] module behind pub(crate) with # Safety doc comments, mirroring xybrid-mlx::ffi’s discipline.

Structs§

LlamaContext
Stub returned when the bindings feature is disabled.
LlamaModel
Stub returned when the bindings feature is disabled.

Enums§

LlamaError
Errors produced by the safe llama.cpp wrappers.

Functions§

backend_init
Initialize the llama.cpp backend and apply Xybrid’s log policy once.
get_verbosity
set_verbosity

Type Aliases§

LlamaResult
Result alias used throughout the safe wrappers.