UNPKG

@assistant-ui/react

Version:

React components for AI chat.

62 lines (61 loc) 2.17 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/api/ContentPartRuntime.ts var ContentPartRuntime_exports = {}; __export(ContentPartRuntime_exports, { ContentPartRuntimeImpl: () => ContentPartRuntimeImpl }); module.exports = __toCommonJS(ContentPartRuntime_exports); 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); } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { ContentPartRuntimeImpl }); //# sourceMappingURL=ContentPartRuntime.js.map