omp packages

pi-response-model0.1.0

Tag Pi assistant messages with the model reported by Responses and Chat Completions APIs.

darrelhong Published 20 days ago MIT ~178 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

pi-response-model

Tag Pi assistant messages with the model reported by the provider, useful when using custom providers that routes between models.

The assistant's answer.

---
Model: gpt-4.1

Requirements

  • Node.js 22.18 or newer

Install

pi install npm:pi-response-model

For local development:

pi install /absolute/path/to/pi-response-model

Or try the extension for one invocation, without installing:

pi --no-extensions -e ./extensions/response-model.ts

Load only one copy. If you already have ~/.pi/agent/extensions/response-model.ts, move that file outside the auto-discovery directory before installing this package. Loading both can add duplicate footers.

Supported APIs

API Non-streaming JSON Streaming SSE
Responses (/responses) Yes Yes: response.completed
Chat Completions (/chat/completions) Yes Yes: first valid model-bearing chunk

The extension inspects cloned successful fetch responses and matches their IDs to finalized assistant messages. It also uses an existing responseModel supplied by Pi if available. It never substitutes the requested model when actual model metadata is absent.

Behaviour and limitations

  • The model name is provider-reported metadata, not independent verification of the underlying model.
  • The footer is appended to assistant text and therefore persisted, copied/exported, and included in subsequent model context. It is not a separate UI-only tag.
  • The extension wraps global fetch and restores it on shutdown when its wrapper is still the active fetch function. Providers that use another HTTP transport are not captured.
  • Response IDs must match. No model inference from the most recent unrelated HTTP response is performed.
  • Captures are limited to the latest 100 response IDs.
  • Successful message finalization waits for pending captures; unfinished unrelated supported-API requests can delay it. Aborted and failed messages do not wait.
  • No styling options are exposed in this version.

Development

No build step or npm dependencies are required for the test suite:

npm run check
npm test
npm pack --dry-run

Tests use mocked fetch responses and native web streams. They cover JSON/SSE parsing, both APIs, early streaming capture, missing model metadata, abort/error handling, fetch restoration, and unchanged original response bodies. Each test has a timeout to avoid stalled CI.

Publish

From the package directory, verify the package and inspect the tarball:

npm run check
npm test
npm pack --dry-run

Log in to npm, then publish the public package:

npm login
npm publish --access public

The prepublishOnly hook runs syntax checks and tests before publication. The package declares Pi as a host-provided peer dependency and does not bundle it.

For subsequent releases, update CHANGELOG.md, bump the version (for example, npm version patch), and publish again with npm publish --access public. npm version creates a Git commit and tag, so start from a clean working tree.

License

MIT. See LICENSE.