@assistant-ui/react
Version:
React components for AI chat.
56 lines • 1.7 kB
JavaScript
// src/api/AssistantRuntime.ts
import { NestedSubscriptionSubject } from "./subscribable/NestedSubscriptionSubject.mjs";
import {
ThreadRuntimeImpl
} from "./ThreadRuntime.mjs";
import { ThreadListRuntimeImpl } from "./ThreadListRuntime.mjs";
var AssistantRuntimeImpl = class _AssistantRuntimeImpl {
constructor(_core, _thread) {
this._core = _core;
this._thread = _thread;
this.threadList = new 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 = ThreadRuntimeImpl) {
return new CustomThreadRuntime(
new NestedSubscriptionSubject({
path: {
ref: "threads.main",
threadSelector: { type: "main" }
},
getState: () => _core.threadList.mainThread,
subscribe: (callback) => _core.threadList.subscribe(callback)
})
);
}
static create(_core, CustomThreadRuntime = ThreadRuntimeImpl) {
return new _AssistantRuntimeImpl(
_core,
_AssistantRuntimeImpl.createMainThreadRuntime(_core, CustomThreadRuntime)
);
}
};
export {
AssistantRuntimeImpl
};
//# sourceMappingURL=AssistantRuntime.mjs.map