0440GitHub
choosekit
Scores a finite set of choices with a model you already run in llama.cpp and returns a typed decision with a probability distribution.
NotXf1le/choosekitREADME ↗
# choosekit
`choosekit` scores a finite set of choices with a language model and returns a typed decision with a probability distribution. It supports local llama.cpp models and an optional OpenRouter backend.
```sh
npm install choosekit
```
## Why
Agents often need to choose from known options:
- approve or reject an action;
- route a message;
- select the next tool;
- classify evidence;
- choose one legal move.
`choosekit` scores choices using the model's conditional log probabilities at the token branches that distinguish them.
The project was inspired by [Jev and the System One model interface](https://typesafe.ai/blog/introducing-system-one-models-and-jev): application state in, typed probabilistic decisions out. Jev is a specialized hosted model. `choosekit` explores the same useful interface with a model you control. The llama.cpp backend keeps application state on infrastructure you choose; OpenRouter is available when a hosted model is more convenient.
`choosekit` is an independent project with no affiliation to TypeSafe or Jev.
## MCP server
[`choosekit-mcp`](packages/choosekit-mcp/README.md) exposes choosekit through llama.cpp or OpenRouter as a read-only stdio tool for Claude Code, Codex, and OpenCode. Select the backend and configure it with environment variables when starting the MCP server. Every `choose` call uses this configuration.
## llama.cpp
```ts
import { fromLlamaCpp } from "choosekit/llama-cpp";
const choose = fromLlamaCpp({
baseURL: "http://127.0.0.1:8080/",
mode: "labels",
});
const decision = await choose({
context: "The deployment modifies production data and no backup exists.",
question: "Should this action run without human approval?",
choices: {
yes: "The action is reversible, low-impact, and within scope.",