UNPKG

@assistant-ui/react

Version:

TypeScript/React library for AI Chat

71 lines 2.9 kB
import { AssistantRuntime } from "../runtime/AssistantRuntime"; /** * @deprecated Use `useAssistantApi()` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12 * * Hook to access the AssistantRuntime from the current context. * * The AssistantRuntime provides access to the top-level assistant state and actions, * including thread management, tool registration, and configuration. * * @param options Configuration options * @param options.optional Whether the hook should return null if no context is found * @returns The AssistantRuntime instance, or null if optional is true and no context exists * * @example * ```tsx * // Before: * function MyComponent() { * const runtime = useAssistantRuntime(); * const handleNewThread = () => { * runtime.switchToNewThread(); * }; * return <button onClick={handleNewThread}>New Thread</button>; * } * * // After: * function MyComponent() { * const api = useAssistantApi(); * const handleNewThread = () => { * api.threads().switchToNewThread(); * }; * return <button onClick={handleNewThread}>New Thread</button>; * } * ``` */ export declare function useAssistantRuntime(options?: { optional?: false | undefined; }): AssistantRuntime; export declare function useAssistantRuntime(options?: { optional?: boolean | undefined; }): AssistantRuntime | null; /** * @deprecated Use `useAssistantState(({ threads }) => threads)` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12 */ export declare const useThreadList: { (): import("../runtime").ThreadListState; <TSelected>(selector: (state: import("../runtime").ThreadListState) => TSelected): TSelected; <TSelected>(selector: ((state: import("../runtime").ThreadListState) => TSelected) | undefined): import("../runtime").ThreadListState | TSelected; (options: { optional?: false | undefined; }): import("../runtime").ThreadListState; (options: { optional?: boolean | undefined; }): import("../runtime").ThreadListState | null; <TSelected>(options: { optional?: false | undefined; selector: (state: import("../runtime").ThreadListState) => TSelected; }): TSelected; <TSelected>(options: { optional?: false | undefined; selector: ((state: import("../runtime").ThreadListState) => TSelected) | undefined; }): import("../runtime").ThreadListState | TSelected; <TSelected>(options: { optional?: boolean | undefined; selector: (state: import("../runtime").ThreadListState) => TSelected; }): TSelected | null; <TSelected>(options: { optional?: boolean | undefined; selector: ((state: import("../runtime").ThreadListState) => TSelected) | undefined; }): import("../runtime").ThreadListState | TSelected | null; }; //# sourceMappingURL=AssistantContext.d.ts.map