Skip to content

About

A Pi provider extension that registers classifier models

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

pi-system-one-provider

License: MIT Pi ≥1.0 Node.js ≥22.19

A Pi provider extension that registers classifier models backed by System One-compatible HTTP endpoints.

It deliberately keeps classifier configuration out of Pi's models.json. The extension reads a separate ~/.pi/agent/classifier-models.json file and treats each provider's baseUrl as the complete endpoint URL. It never appends /v1/systemone or any other path. Classification, image encoding, retries, cancellation, and usage accounting are delegated to Pi's built-in System One implementation; a small adapter forwards its requests to the configured URL.

Requirements

  • Pi 1.0 or later for text classification; Pi 1.4.0 or later for image input and compat settings
  • Node.js 22.19 or later when developing the package

Install

Install directly from GitHub:

pi install git:github.com/yshrkt/pi-system-one-provider

To pin a release, append an existing tag to the source, for example @v0.1.0 once that release is tagged.

For local development, install from your checkout:

pi install ./path/to/pi-system-one-provider

Configure

Create ~/.pi/agent/classifier-models.json:

{
  "providers": {
    "ollama-system-one": {
      "name": "Local System One",
      "baseUrl": "http://localhost:11434/v1/systemone",
      "models": [
        {
          "id": "clef-flash",
          "name": "Clef Flash"
        },
        {
          "id": "nimble",
          "name": "Nimble",
          "contextWindow": 65536
        }
      ]
    }
  }
}

The same configuration is available at examples/classifier-models.json.

baseUrl is the URL that receives the POST request. The example above is used exactly as written; the extension does not turn it into http://localhost:11434/v1/systemone/v1/systemone.

Use a dedicated provider ID such as ollama-system-one. Registering the same provider ID as another Pi provider replaces that provider's model list.

Provider fields:

Field Required Description
baseUrl yes Complete http or https System One endpoint URL
models yes Non-empty array of classifier models
name no Provider display name
apiKey no Pi config value: literal, $ENV_VAR, ${ENV_VAR}, or !command
headers no Additional request headers

Model fields:

Field Required Default
id yes —
name no id
contextWindow no 65536
input no ["text"]; supported modalities: "text", "image"
compat no Pi's System One compatibility defaults
cost no all rates 0

For an authenticated endpoint:

{
  "providers": {
    "hosted-system-one": {
      "baseUrl": "https://example.com/v1/systemone",
      "apiKey": "$SYSTEM_ONE_API_KEY",
      "models": [{ "id": "security-one" }]
    }
  }
}

Pi resolves the key and the extension sends it as Authorization: Bearer .... When apiKey is omitted, no Authorization header is sent. You can also supply a custom authorization scheme through headers.

To use a different config location, set PI_SYSTEM_ONE_CONFIG to its path before starting Pi.

Image input

Image input and compat settings require Pi 1.4.0 or later. Older versions reject these settings with an upgrade message.

To enable images, add "image" to the model's input and select the format your endpoint accepts. For a Clef-compatible endpoint:

{
  "id": "clef-flash",
  "input": ["text", "image"],
  "compat": {
    "imageInput": "images",
    "sendImageOptInHeader": false
  }
}

compat supports these optional fields:

Field Values Meaning
imageInput "assets", "images", "ollama-images", "state-image-urls" TypeSafe assets, Clef data URLs, Ollama raw Base64 strings, or OpenRouter image parts in state
sendImageOptInHeader true, false Send TypeSafe-Danger-Zone-Images: true with image requests

For an Ollama System One endpoint that expects raw Base64 strings in images, use:

{
  "id": "d1:3b",
  "input": ["text", "image"],
  "compat": {
    "imageInput": "ollama-images",
    "sendImageOptInHeader": false
  }
}

ollama-images is an extension-specific setting. The extension registers it with Pi as images and removes the data:image/...;base64, prefix from each string immediately before sending the request. The wire format is "images": ["/9j/..."]. The existing images setting continues to send Data URLs such as "images": ["data:image/jpeg;base64,/9j/..."].

Without overrides, Pi uses state-image-urls without the opt-in header for provider ID openrouter or URLs containing openrouter.ai; otherwise it uses assets with the opt-in header. Set both fields explicitly for local endpoints and proxies as needed. The endpoint and selected model must support the chosen format. Pi validates supported image formats and limits: assets accepts PNG/JPEG, and images and ollama-images accept PNG/JPEG/WebP with at most four images.

Pass images as images: [{ type: "image", mimeType: "image/png", data: "<base64 image bytes>" }] alongside state and questions in the classification context. data contains raw base64, without a data URL prefix. Models that omit input remain text-only and reject image input.

Existing configuration files and complete endpoint URLs continue to work without edits on Pi 1.0 or later. The registered API remains system-one-endpoint.

Use from codemode

Enable Pi's built-in codemode extension, then discover and invoke the registered classifier:

const model = await models.getModelOfType("classifier", "ollama-system-one", "clef-flash");
const result = await models.classify(model, {
  state: { text: "The deployment removed authentication from the admin route." },
  questions: {
    severity: {
      type: "score",
      instructions: "How severe is this change?",
      criteria: ["low", "medium", "high"]
    },
    securityRelevant: {
      type: "bool",
      instructions: "Is this security relevant?",
      criteria: { "true": "security impact", "false": "no security impact" }
    }
  }
});
text(result);

Pi's public bool question type is translated to System One's wire-level noul type. choice and score pass through unchanged. The request includes the selected model ID so endpoints such as Ollama can route multiple models through the same URL.

Bundled skill

The package also includes system-one-classify, a skill that teaches Pi how to discover classifier models, choose question types, call them through codemode, and interpret results. Pi can load it when relevant, or you can invoke it explicitly:

/skill:system-one-classify Use ollama-system-one/clef-flash:latest to classify the sentiment of: "This product is convenient and I love using it."

Replace the provider/model with an ID from your configuration. There is no default classifier setting; specify your preference in the prompt or AGENTS.md. The skill discovers available models when no preference is given.

Codemode must be enabled. To try the package and bundled skill from a checkout:

PI_SYSTEM_ONE_CONFIG="$PWD/examples/classifier-models.json" \
  pi -e . --tools read,bash,edit,write,codemode

Restart Pi or run /reload after updating the package to discover the new skill.

Develop

npm install
npm run check

The tests verify configuration validation, exact endpoint handling, authentication, question translation, all four image formats, retries, and usage costs without requiring a live model server. They also classify text and images from a copy without node_modules through Pi's actual extension loader and provider composition.

License

MIT License. Copyright © 2026 Yoshihiro Kato. See LICENSE for details.

About

A Pi provider extension that registers classifier models

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages