UNPKG

@assistant-ui/react

Version:

React components for AI chat.

79 lines (78 loc) 2.87 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/AssistantRuntime.ts var AssistantRuntime_exports = {}; __export(AssistantRuntime_exports, { AssistantRuntimeImpl: () => AssistantRuntimeImpl }); module.exports = __toCommonJS(AssistantRuntime_exports); var import_NestedSubscriptionSubject = require("./subscribable/NestedSubscriptionSubject.cjs"); var import_ThreadRuntime = require("./ThreadRuntime.cjs"); var import_ThreadListRuntime = require("./ThreadListRuntime.cjs"); var AssistantRuntimeImpl = class _AssistantRuntimeImpl { constructor(_core, _thread) { this._core = _core; this._thread = _thread; this.threadList = new import_ThreadListRuntime.ThreadListRuntimeImpl(_core.threadList); } threadList; get thread() { return this._thread; } switchToNewThread() { return this._core.threadList.switchToNewThread(); } switchToThread(threadId) { if (threadId === null) return this.switchToNewThread(); return this._core.threadList.switchToThread(threadId); } registerModelConfigProvider(provider) { return this._core.registerModelConfigProvider(provider); } /** * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0. */ subscribe() { return () => { }; } static createMainThreadRuntime(_core, CustomThreadRuntime = import_ThreadRuntime.ThreadRuntimeImpl) { return new CustomThreadRuntime( new import_NestedSubscriptionSubject.NestedSubscriptionSubject({ path: { ref: "threads.main", threadSelector: { type: "main" } }, getState: () => _core.threadList.mainThread, subscribe: (callback) => _core.threadList.subscribe(callback) }) ); } static create(_core, CustomThreadRuntime = import_ThreadRuntime.ThreadRuntimeImpl) { return new _AssistantRuntimeImpl( _core, _AssistantRuntimeImpl.createMainThreadRuntime(_core, CustomThreadRuntime) ); } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { AssistantRuntimeImpl }); //# sourceMappingURL=AssistantRuntime.js.map