@camera.ui/sdk / plugin / AssistantModelProvider
Interface: AssistantModelProvider ​
Defined in: plugin/assistant-models.ts:164
Implemented by plugins that list PluginInterface.AssistantModels in their contract. Such a plugin is a bridge to a model the host cannot reach itself: one without an HTTP API, one behind an unusual authentication, or one that lives on the machine the plugin runs on. The plugin holds no conversation state, every request carries the whole conversation.
Example ​
class ApplePlugin extends BasePlugin implements AssistantModelProvider {
assistantModels(): AssistantModelSpec[] {
return [{ id: 'apple-on-device', name: 'Apple on-device', contextTokens: 8192, vision: true, toolCalling: true, structuredOutput: true }];
}
async *assistantGenerate(request: AssistantModelRequest, ctx: AssistantModelContext): AsyncGenerator<AssistantModelChunk> {
for await (const delta of this.session.stream(request, ctx.timeoutMs)) {
yield { type: 'text', delta };
}
yield { type: 'done', finish: 'stop' };
}
}Methods ​
assistantGenerate() ​
assistantGenerate(
request,ctx):AsyncGenerator<AssistantModelChunk>
Defined in: plugin/assistant-models.ts:203
Answer one request. The host reads chunks until done, then either returns the text to the user or runs the tool calls and asks again with their results in messages.
Parameters ​
request ​
Conversation, tools and schema for this answer.
ctx ​
Who asks, in which language, and how long the host waits.
Returns ​
AsyncGenerator<AssistantModelChunk>
The answer in pieces (see AssistantModelChunk).
assistantModels() ​
assistantModels():
AssistantModelSpec[] |Promise<AssistantModelSpec[]>
Defined in: plugin/assistant-models.ts:172
List the models this plugin offers. Called after the plugin is ready and whenever the settings page is opened.
Returns ​
AssistantModelSpec[] | Promise<AssistantModelSpec[]>
The specs, empty while the plugin has no usable model (no hardware, no permission yet).
assistantModelStatus()? ​
optionalassistantModelStatus():AssistantModelStatus|Promise<AssistantModelStatus>
Defined in: plugin/assistant-models.ts:190
Report whether the models can answer right now. The host asks before it offers them and while the settings page is open, so a model that is still downloading shows up as busy instead of missing. Leave it out when the models are usable as soon as the plugin runs.
Returns ​
AssistantModelStatus | Promise<AssistantModelStatus>
Readiness, with a line and a progress while it loads.
Example ​
async assistantModelStatus(): Promise<AssistantModelStatus> {
const { loaded, total } = this.download;
return loaded < total ? { ready: false, message: 'Loading the model', progress: loaded / total } : { ready: true };
}