import { UseGenerationOptions, UseGenerationReturn } from "./use-generation.js"; import { Accessor } from "solid-js"; import { AIDevtoolsDisplayOptions, AudioGenerateInput, ConnectConnectionAdapter, GenerationClientState, GenerationFetcher, GenerationPersistenceOptions, InferGenerationOutputFromReturn } from "@tanstack/ai-client"; import { AudioGenerationResult, StreamChunk } from "@tanstack/ai"; //#region src/use-generate-audio.d.ts /** * Options for the useGenerateAudio hook. * * @template TOutput - The transformed output type (defaults to AudioGenerationResult) */ interface UseGenerateAudioOptions extends Pick, 'persistence' | 'threadId' | 'hydrateGeneration' | 'joinRun' | 'byok' | 'byokProvider'> { /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */ connection?: ConnectConnectionAdapter; /** Direct async function for audio generation */ fetcher?: GenerationFetcher; /** Additional body parameters to send with connect-based adapter requests */ body?: Record; /** Display options for TanStack AI Devtools. */ devtools?: AIDevtoolsDisplayOptions; /** * Callback when audio is generated. Can optionally return a transformed value. * * - Return a non-null value to transform and store it as the result * - Return `null` to keep the previous result unchanged * - Return nothing (`void`) to store the raw result as-is */ onResult?: (result: AudioGenerationResult) => TOutput | null | void; /** Callback when an error occurs */ onError?: (error: Error) => void; /** Callback when progress is reported (0-100) */ onProgress?: (progress: number, message?: string) => void; /** Callback for each stream chunk (connect-based adapter mode only) */ onChunk?: (chunk: StreamChunk) => void; } /** * Return type for the useGenerateAudio hook. * * @template TOutput - The transformed output type (defaults to AudioGenerationResult) */ interface UseGenerateAudioReturn extends Omit, 'generate'> { /** Trigger audio generation */ generate: (input: AudioGenerateInput) => Promise; /** The generation result containing audio, or null */ result: Accessor; /** Whether generation is in progress */ isLoading: Accessor; /** Current error, if any */ error: Accessor; /** Current state of the generation */ status: Accessor; } /** * Solid hook for generating audio (music, sound effects) using AI models. * * @example * ```tsx * import { useGenerateAudio } from '@tanstack/ai-solid' * import { fetchServerSentEvents } from '@tanstack/ai-client' * * function AudioGenerator() { * const { generate, result, isLoading } = useGenerateAudio({ * connection: fetchServerSentEvents('/api/generate/audio'), * }) * * return ( *
* * {result()?.audio.url &&
* ) * } * ``` */ declare function useGenerateAudio(options: Omit & { onResult?: (result: AudioGenerationResult) => TTransformed; } & GenerationPersistenceOptions): UseGenerateAudioReturn>; //#endregion export { UseGenerateAudioOptions, UseGenerateAudioReturn, useGenerateAudio }; //# sourceMappingURL=use-generate-audio.d.ts.map