Install
This page adds troupekit to your own Rust project and helps you pick the Cargo features you need. If you only want to see it run first, the Quick start is shorter.
Requirements
You need Rust 1.89 or newer, the rust-version of troupekit, troupekit-kit, troupekit-store-sqlite, troupekit-cli and the binding crates; the other engine crates need 1.85. Troupekit is async, so you also need a tokio runtime; the examples use #[tokio::main].
The default build needs a C compiler: the sqlite feature compiles the bundled SQLite from C, and the TLS stack behind reqwest builds aws-lc-sys from C too. The llama feature adds a C++ compiler and cmake 3.14 or newer.
Add the dependency
Troupekit is on crates.io. The quickest way to add it is with Cargo:
cargo add troupekit
cargo add tokio --features rt-multi-thread,macros
That gives you these lines in Cargo.toml:
[dependencies]
troupekit = "0.4"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
To try unreleased changes on main, depend on the repository instead: troupekit = { git = "https://github.com/ChaoticQubit/troupekit", branch = "main" }. Pin a released version for anything you ship.
Pick features
The defaults, sqlite, reqwest and kit, give you agents, tools, hosted models and the SQLite store. Add other features in the dependency line:
troupekit = { version = "0.4", features = ["knowledge"] }
With cargo add, that is cargo add troupekit --features knowledge.
| Feature | Adds |
|---|---|
kit | The #[agent] and #[tool] macros and the Agent and Graph builders. Default. |
sqlite | All five stores in one SQLite file. Default. |
reqwest | The HTTP transport for hosted models and web tools. Default. |
knowledge | Folder search and long-term memory: Knowledge, AgentMemory, hybrid search. |
local | On-device models through the LocalModel trait. |
llama | llama.cpp behind local, for GGUF files. |
sqlcipher | An encrypted SQLite file, with vendored OpenSSL. |
sqlcipher-system | An encrypted SQLite file, with the system crypto library. |
Feature flags lists the flags of every crate.
Build llama.cpp
With the llama feature, the build script compiles llama.cpp from source, so it needs that source on disk. In a clone of the repository, fetch it with:
cargo xtask fetch-llama
The command downloads one pinned llama.cpp release, checks its SHA-256 and unpacks it into crates/troupekit-local/llama.cpp. In your own project there is no such command, so point the build at llama.cpp with one of two variables. TROUPEKIT_LLAMA_SRC names a llama.cpp checkout to build. TROUPEKIT_LLAMA_LIB_DIR names a folder with a prebuilt libllama and tk_llama, which skips the C++ build.
On macOS and iOS the build turns on Metal, Apple's GPU API, unless you set TROUPEKIT_LLAMA_METAL=0. An Android build needs ANDROID_NDK_HOME.
Install the command line
The troupekit-cli crate builds a binary called troupekit:
cargo install troupekit-cli
It has two commands. troupekit ingest builds a searchable index from a folder, as Knowledge shows, and troupekit trace shows a trace, as Tracing and budgets shows.