From ecbb912e149892851680e23eb31493f3ca02065f Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Sat, 26 Oct 2024 13:05:14 -0700 Subject: [PATCH] docs: add some jsdocs to runtimes (#1094) --- packages/react/src/api/AssistantRuntime.ts | 20 +++++++++++++++++ packages/react/src/api/ThreadRuntime.ts | 26 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/packages/react/src/api/AssistantRuntime.ts b/packages/react/src/api/AssistantRuntime.ts index 1b14d4edd..0856a944c 100644 --- a/packages/react/src/api/AssistantRuntime.ts +++ b/packages/react/src/api/AssistantRuntime.ts @@ -13,17 +13,37 @@ import { } from "./ThreadManagerRuntime"; export type AssistantRuntime = { + /** + * The currently selected main thread. + */ thread: ThreadRuntime; + + /** + * The thread manager, to rename, archive and delete threads. + */ threadManager: ThreadManagerRuntime; + /** + * Switch to a new thread. + */ switchToNewThread(): void; + /** + * Switch to a thread. + * + * @param threadId The thread ID to switch to. + */ switchToThread(threadId: string): void; /** * @deprecated Use `switchToNewThread` instead. This will be removed in 0.6.0. */ switchToThread(threadId: string | null): void; + /** + * Register a model config provider. Model config providers are configuration such as system message, temperature, etc. that are set in the frontend. + * + * @param provider The model config provider to register. + */ registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe; /** diff --git a/packages/react/src/api/ThreadRuntime.ts b/packages/react/src/api/ThreadRuntime.ts index 4d2a00e1c..554ed6077 100644 --- a/packages/react/src/api/ThreadRuntime.ts +++ b/packages/react/src/api/ThreadRuntime.ts @@ -77,12 +77,38 @@ export type ThreadRuntimeCoreBinding = SubscribableWithState< }; export type ThreadState = Readonly<{ + /** + * The thread ID. + */ threadId: string; + /** + * Whether the thread is disabled. Disabled threads cannot receive new messages. + */ isDisabled: boolean; + + /** + * Whether the thread is running. A thread is considered running when there is an active stream connection to the backend. + */ isRunning: boolean; + + /** + * The capabilities of the thread, such as whether the thread supports editing, branch switching, etc. + */ capabilities: RuntimeCapabilities; + + /** + * The messages in the currently selected branch of the thread. + */ messages: readonly ThreadMessage[]; + + /** + * Follow up message suggestions to show the user. + */ suggestions: readonly ThreadSuggestion[]; + + /** + * Custom extra information provided by the runtime. + */ extras: unknown; /**