import type { UseQueryOptions } from "@tanstack/react-query"; import type TamboAI from "@tambo-ai/typescript-sdk"; import type { SuggestionCreateResponse, SuggestionListResponse } from "@tambo-ai/typescript-sdk/resources/threads/suggestions"; /** * Response type for suggestions queries (union of list and create responses) */ type SuggestionsQueryResponse = SuggestionListResponse | SuggestionCreateResponse; /** * Configuration options for the useTamboSuggestions hook */ export interface UseTamboSuggestionsOptions { /** Maximum number of suggestions to generate (1-10, default 3) */ maxSuggestions?: number; /** * Whether to automatically generate suggestions when the latest message is from the assistant. * Default: true */ autoGenerate?: boolean; /** * Additional React Query options for the suggestions query. * Allows customizing caching, refetching behavior, etc. */ queryOptions?: Omit, "queryKey" | "queryFn" | "enabled">; } /** * Options for accepting a suggestion */ export interface AcceptSuggestionOptions { /** The suggestion to accept */ suggestion: TamboAI.Beta.Threads.Suggestion; /** Whether to automatically submit the suggestion after accepting (default: false) */ shouldSubmit?: boolean; } /** * Return type for useTamboSuggestions hook */ export interface UseTamboSuggestionsReturn { /** * The raw response data from the suggestions query. * Use this for direct access to the API response shape. */ data: SuggestionsQueryResponse | undefined; /** List of available suggestions for the current message (convenience accessor) */ suggestions: TamboAI.Beta.Threads.Suggestion[]; /** Whether the suggestions query is loading (first fetch) */ isLoading: boolean; /** Whether suggestions have been successfully loaded */ isSuccess: boolean; /** Whether there was an error loading suggestions */ isError: boolean; /** Error from loading suggestions, if any */ error: Error | null; /** Whether the query is currently fetching (includes background refetches) */ isFetching: boolean; /** * Manually generate new suggestions for the current message. * Use this when autoGenerate is false or to refresh suggestions. */ generate: () => Promise; /** Whether suggestions are being generated (mutation pending) */ isGenerating: boolean; /** Error from generating suggestions, if any */ generateError: Error | null; /** * Accept and apply a suggestion. * Sets the suggestion text as input value, optionally submitting it. */ accept: (options: AcceptSuggestionOptions) => Promise; /** Whether accepting a suggestion is in progress */ isAccepting: boolean; /** Error from accepting a suggestion, if any */ acceptError: Error | null; /** ID of the currently selected suggestion */ selectedSuggestionId: string | null; } /** * Hook for managing AI-powered suggestions in a thread. * * Provides functionality to: * - Automatically generate suggestions when an assistant message arrives * - Manually generate suggestions on demand * - Accept suggestions by setting them as input or auto-submitting * @param options - Configuration options * @returns Suggestions state and control functions * @example * ```tsx * function SuggestionsPanel() { * const { * suggestions, * accept, * isLoading, * selectedSuggestionId, * } = useTamboSuggestions(); * * if (isLoading) return ; * * return ( *
* {suggestions.map((suggestion) => ( * * ))} *
* ); * } * ``` */ export declare function useTamboSuggestions(options?: UseTamboSuggestionsOptions): UseTamboSuggestionsReturn; export {}; //# sourceMappingURL=use-tambo-v1-suggestions.d.ts.map