UNPKG

@assistant-ui/react

Version:

TypeScript/React library for AI Chat

41 lines 1.19 kB
import { BaseComposerRuntimeCore } from "./BaseComposerRuntimeCore.js"; export class DefaultThreadComposerRuntimeCore extends BaseComposerRuntimeCore { runtime; _canCancel = false; get canCancel() { return this._canCancel; } get attachments() { return super.attachments; } getAttachmentAdapter() { return this.runtime.adapters?.attachments; } getDictationAdapter() { return this.runtime.adapters?.dictation; } constructor(runtime) { super(); this.runtime = runtime; this.connect(); } connect() { return this.runtime.subscribe(() => { if (this.canCancel !== this.runtime.capabilities.cancel) { this._canCancel = this.runtime.capabilities.cancel; this._notifySubscribers(); } }); } async handleSend(message) { this.runtime.append({ ...message, parentId: this.runtime.messages.at(-1)?.id ?? null, sourceId: null, }); } async handleCancel() { this.runtime.cancelRun(); } } //# sourceMappingURL=DefaultThreadComposerRuntimeCore.js.map