UNPKG

@assistant-ui/react

Version:

React components for AI chat.

37 lines 1.1 kB
// src/api/ContentPartRuntime.ts var ContentPartRuntimeImpl = class { constructor(contentBinding, messageApi, threadApi) { this.contentBinding = contentBinding; this.messageApi = messageApi; this.threadApi = threadApi; } get path() { return this.contentBinding.path; } getState() { return this.contentBinding.getState(); } addToolResult(result) { const message = this.messageApi.getState(); if (!message) throw new Error("Message is not available"); const state = this.contentBinding.getState(); if (!state) throw new Error("Content part is not available"); if (state.type !== "tool-call") throw new Error("Tried to add tool result to non-tool content part"); const toolName = state.toolName; const toolCallId = state.toolCallId; this.threadApi.getState().addToolResult({ messageId: message.id, toolName, toolCallId, result }); } subscribe(callback) { return this.contentBinding.subscribe(callback); } }; export { ContentPartRuntimeImpl }; //# sourceMappingURL=ContentPartRuntime.mjs.map