UNPKG

@assistant-ui/react

Version:

React components for AI chat.

78 lines (77 loc) 2.78 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/runtimes/local/LocalRuntimeCore.tsx var LocalRuntimeCore_exports = {}; __export(LocalRuntimeCore_exports, { LocalRuntimeCore: () => LocalRuntimeCore }); module.exports = __toCommonJS(LocalRuntimeCore_exports); var import_BaseAssistantRuntimeCore = require("../core/BaseAssistantRuntimeCore.cjs"); var import_LocalThreadRuntimeCore = require("./LocalThreadRuntimeCore.cjs"); var import_fromCoreMessage = require("../edge/converters/fromCoreMessage.cjs"); var import_LocalThreadListRuntimeCore = require("./LocalThreadListRuntimeCore.cjs"); var getExportFromInitialMessages = (initialMessages) => { const messages = (0, import_fromCoreMessage.fromCoreMessages)(initialMessages); return { messages: messages.map((m, idx) => ({ parentId: messages[idx - 1]?.id ?? null, message: m })) }; }; var LocalRuntimeCore = class extends import_BaseAssistantRuntimeCore.BaseAssistantRuntimeCore { threadList; _options; constructor(options, initialMessages) { super(); this._options = options; this.threadList = new import_LocalThreadListRuntimeCore.LocalThreadListRuntimeCore((threadId, data) => { const thread = new import_LocalThreadRuntimeCore.LocalThreadRuntimeCore( this._proxyConfigProvider, threadId, this._options ); thread.import(data); return thread; }); if (initialMessages) { this.threadList.mainThread.import( getExportFromInitialMessages(initialMessages) ); } } setOptions(options) { this._options = options; this.threadList.mainThread.setOptions(options); } reset({ initialMessages } = {}) { this.threadList.switchToNewThread(); if (!initialMessages) return; this.threadList.mainThread.import( getExportFromInitialMessages(initialMessages) ); } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { LocalRuntimeCore }); //# sourceMappingURL=LocalRuntimeCore.js.map