Repository navigation
Conversation
Extensions could shape requests and read models, but not add a provider of their own: a module that brings a new service had no way to give its models to Pi. `host.registerModelProvider(provider, config)` registers Pi's own `ProviderConfig` with the model runtime, and its return value removes the provider again. The cleanup leaves a newer registration alone: a reloaded module starts before the old version's cleanups run, so without the guard an edit would take out the provider the new version just put in. The provider's models appear at Pi's next model refresh, as with Refresh models. Docs and types say it is experimental in 0.20.0. The test loads a drop-in that registers a provider, checks a reload keeps it, and checks that turning the module off removes it (it fails without the guard).
|
I tested this branch with a real provider that has a dynamic catalog: Charm Hyper. Setup: a drop-in calls Result:
Two findings:
refreshModels: async ({ allowNetwork, stored, ...rest }) => {
if (!allowNetwork) return stored?.models ?? [];
// fetch the live catalog
}A sentence in the reference and a test for this path would help. I can add the test if you want it. The rest of the design works for a real provider. |
Two findings from a test with a real dynamic provider (Charm Hyper): a provider without a static models list shows nothing until a network refresh, and a refreshModels that ignores allowNetwork and returns [] empties the catalog on every local pass, before the network pass can restore it. The reference now tells authors about both: ship a fallback models list, and return the stored catalog when allowNetwork is false.
|
Thanks — both findings check out, and I traced them to the runtime to be sure:
I have pushed 0c628ac, which adds both to the A test for the local-pass path is a good addition — please do add it if you have the setup fresh; otherwise I'll write one along the original drop-in's lines (register with |
What changed
host.registerModelProvider(provider, config)to the extension host (server,types/pocket.d.ts, and the reference docs), backed byModelRuntime.registerProvider/unregisterProvider.ProviderConfig(name, base URL, API, key, headers, models orrefreshModels), and returns a function that removes the provider.test/model-providers.test.ts: a drop-in registers a provider, a reload keeps it, turning the module off removes it. I verified it fails without the registration guard.Why
Extensions can shape model requests and read models, but a module that brings its own service could not give its models to Pi. This is the extension point that lets a drop-in (for example a provider package beside it) make its models selectable in every session.
Tested
npm run checknpm run lintnpm test(385 passing)