omp packages

@steveimm/pi-chat-template-kwargs0.2.0

Pi extension: override chat_template_kwargs on the fly via /ctk

GitHub Actions Published 3 days ago MIT ~287 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

@steveimm/pi-chat-template-kwargs

A pi extension to override the chat_template_kwargs request-body field on the fly, mid-session, without editing model config or restarting.

Useful for self-hosted inference servers such as llama.cpp, vLLM, SGLang, to override chat-template variables like reasoning_strength, enable_thinking, etc.

[!NOTE] Only applies to models using the openai-completions (includes llama.cpp) API. Other providers are left untouched.

Install

After the package is published to npm:

pi install npm:@steveimm/pi-chat-template-kwargs

To try the local package from the repository root:

npm ci
pi --no-extensions -e ./packages/pi-chat-template-kwargs

Usage

Run /ctk to open a toggle view in TUI mode. It lists your saved overrides, and a highlighted row under the title shows the combination of all enabled items.

  • ↑/↓ move the cursor
  • space toggles the item under the cursor on or off
  • n creates a new override: type valid JSON in the view and press enter to save it, shift+enter for a new line, esc to go back. Invalid or duplicate input is rejected with a message
  • d deletes the override under the cursor, after an in-view confirmation (enter to delete, esc to go back)
  • esc closes; the enabled combination becomes the active override

Items are marked with a filled bullet ● when enabled and a hollow bullet ○ when off. With nothing enabled the preview shows {} and no override is active.

You can also pass an override as an argument to make it the only active one, which is how it works in non-TUI modes.

/ctk {"reasoning_strength": "low"}
/ctk off

How it works

The extension intercepts before_provider_request hook, which fires right before each request is sent to the provider, and modifies the payload there.

The active override is the merge of all enabled saved items, in list order. It is applied last and merged key by key into whatever chat_template_kwargs the payload already carries, so it updates matching keys and adds new ones rather than fully replacing the object. Later items override earlier ones on conflicting keys.

The enabled items are session state. They reset when the session is replaced (new, resumed, or forked) or when Pi reloads extensions.

Overrides are stored in ~/.pi/agent/chat-template-kwargs.json as a JSON array of kwargs objects and can be edited directly. The file is reloaded on every session start, so edits are picked up without a restart. The file must stay a JSON array of objects; anything else is reported as a load error and blocks /ctk until fixed.

Overrides are matched key-order-independently, so {"a":1,"b":2} and {"b":2,"a":1} are the same override.

[
	{ "reasoning_strength": "low" },
	{ "enable_thinking": false }
]

License

MIT