@tanstack/ai-svelte 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,92 @@
1
+ import type { ImageGenerationResult, StreamChunk } from '@tanstack/ai';
2
+ import type { ConnectionAdapter, GenerationClientState, GenerationFetcher, ImageGenerateInput, InferGenerationOutput } from '@tanstack/ai-client';
3
+ /**
4
+ * Options for the createGenerateImage function.
5
+ *
6
+ * @template TOutput - The output type after optional transform (defaults to ImageGenerationResult)
7
+ */
8
+ export interface CreateGenerateImageOptions<TOutput = ImageGenerationResult> {
9
+ /** Connection adapter for streaming transport (SSE, HTTP stream, custom) */
10
+ connection?: ConnectionAdapter;
11
+ /** Direct async function for image generation */
12
+ fetcher?: GenerationFetcher<ImageGenerateInput, ImageGenerationResult>;
13
+ /** Unique identifier for this generation instance */
14
+ id?: string;
15
+ /** Additional body parameters to send with ConnectionAdapter requests */
16
+ body?: Record<string, any>;
17
+ /**
18
+ * Callback when images are generated. Can optionally return a transformed value.
19
+ *
20
+ * - Return a non-null value to transform and store it as the result
21
+ * - Return `null` to keep the previous result unchanged
22
+ * - Return nothing (`void`) to store the raw result as-is
23
+ */
24
+ onResult?: (result: ImageGenerationResult) => TOutput | null | void;
25
+ /** Callback when an error occurs */
26
+ onError?: (error: Error) => void;
27
+ /** Callback when progress is reported (0-100) */
28
+ onProgress?: (progress: number, message?: string) => void;
29
+ /** Callback for each stream chunk (ConnectionAdapter mode only) */
30
+ onChunk?: (chunk: StreamChunk) => void;
31
+ }
32
+ /**
33
+ * Return type for the createGenerateImage function.
34
+ *
35
+ * @template TOutput - The output type (after optional transform)
36
+ */
37
+ export interface CreateGenerateImageReturn<TOutput = ImageGenerationResult> {
38
+ /** The generation result containing images, or null */
39
+ readonly result: TOutput | null;
40
+ /** Whether generation is in progress */
41
+ readonly isLoading: boolean;
42
+ /** Current error, if any */
43
+ readonly error: Error | undefined;
44
+ /** Current state of the generation */
45
+ readonly status: GenerationClientState;
46
+ /** Trigger image generation */
47
+ generate: (input: ImageGenerateInput) => Promise<void>;
48
+ /** Abort the current generation */
49
+ stop: () => void;
50
+ /** Clear result, error, and return to idle */
51
+ reset: () => void;
52
+ /** Update additional body parameters */
53
+ updateBody: (body: Record<string, any>) => void;
54
+ }
55
+ /**
56
+ * Creates a reactive image generation instance for Svelte 5.
57
+ *
58
+ * Supports two transport modes:
59
+ * - **ConnectionAdapter** -- Streaming transport (SSE, HTTP stream, custom)
60
+ * - **Fetcher** -- Direct async function call
61
+ *
62
+ * @example
63
+ * ```svelte
64
+ * <script>
65
+ * import { createGenerateImage, fetchServerSentEvents } from '@tanstack/ai-svelte'
66
+ *
67
+ * const imageGen = createGenerateImage({
68
+ * connection: fetchServerSentEvents('/api/generate/image'),
69
+ * })
70
+ * </script>
71
+ *
72
+ * <div>
73
+ * <button onclick={() => imageGen.generate({ prompt: 'A sunset over mountains' })}>
74
+ * Generate
75
+ * </button>
76
+ * {#if imageGen.isLoading}
77
+ * <p>Generating...</p>
78
+ * {/if}
79
+ * {#if imageGen.error}
80
+ * <p>Error: {imageGen.error.message}</p>
81
+ * {/if}
82
+ * {#if imageGen.result}
83
+ * {#each imageGen.result.images as img}
84
+ * <img src={img.url || `data:image/png;base64,${img.b64Json}`} alt="Generated" />
85
+ * {/each}
86
+ * {/if}
87
+ * </div>
88
+ * ```
89
+ */
90
+ export declare function createGenerateImage<TOnResult extends ((result: ImageGenerationResult) => any) | undefined = undefined>(options: Omit<CreateGenerateImageOptions, 'onResult'> & {
91
+ onResult?: TOnResult;
92
+ }): CreateGenerateImageReturn<InferGenerationOutput<ImageGenerationResult, TOnResult>>;
@@ -0,0 +1,57 @@
1
+ import { createGeneration } from './create-generation.svelte';
2
+ /**
3
+ * Creates a reactive image generation instance for Svelte 5.
4
+ *
5
+ * Supports two transport modes:
6
+ * - **ConnectionAdapter** -- Streaming transport (SSE, HTTP stream, custom)
7
+ * - **Fetcher** -- Direct async function call
8
+ *
9
+ * @example
10
+ * ```svelte
11
+ * <script>
12
+ * import { createGenerateImage, fetchServerSentEvents } from '@tanstack/ai-svelte'
13
+ *
14
+ * const imageGen = createGenerateImage({
15
+ * connection: fetchServerSentEvents('/api/generate/image'),
16
+ * })
17
+ * </script>
18
+ *
19
+ * <div>
20
+ * <button onclick={() => imageGen.generate({ prompt: 'A sunset over mountains' })}>
21
+ * Generate
22
+ * </button>
23
+ * {#if imageGen.isLoading}
24
+ * <p>Generating...</p>
25
+ * {/if}
26
+ * {#if imageGen.error}
27
+ * <p>Error: {imageGen.error.message}</p>
28
+ * {/if}
29
+ * {#if imageGen.result}
30
+ * {#each imageGen.result.images as img}
31
+ * <img src={img.url || `data:image/png;base64,${img.b64Json}`} alt="Generated" />
32
+ * {/each}
33
+ * {/if}
34
+ * </div>
35
+ * ```
36
+ */
37
+ export function createGenerateImage(options) {
38
+ const gen = createGeneration(options);
39
+ return {
40
+ get result() {
41
+ return gen.result;
42
+ },
43
+ get isLoading() {
44
+ return gen.isLoading;
45
+ },
46
+ get error() {
47
+ return gen.error;
48
+ },
49
+ get status() {
50
+ return gen.status;
51
+ },
52
+ generate: gen.generate,
53
+ stop: gen.stop,
54
+ reset: gen.reset,
55
+ updateBody: gen.updateBody,
56
+ };
57
+ }
@@ -0,0 +1,83 @@
1
+ import type { StreamChunk, TTSResult } from '@tanstack/ai';
2
+ import type { ConnectionAdapter, GenerationClientState, GenerationFetcher, InferGenerationOutput, SpeechGenerateInput } from '@tanstack/ai-client';
3
+ /**
4
+ * Options for the createGenerateSpeech function.
5
+ *
6
+ * @template TOutput - The output type after optional transform (defaults to TTSResult)
7
+ */
8
+ export interface CreateGenerateSpeechOptions<TOutput = TTSResult> {
9
+ /** Connection adapter for streaming transport (SSE, HTTP stream, custom) */
10
+ connection?: ConnectionAdapter;
11
+ /** Direct async function for speech generation */
12
+ fetcher?: GenerationFetcher<SpeechGenerateInput, TTSResult>;
13
+ /** Unique identifier for this generation instance */
14
+ id?: string;
15
+ /** Additional body parameters to send with ConnectionAdapter requests */
16
+ body?: Record<string, any>;
17
+ /**
18
+ * Callback when speech is generated. Can optionally return a transformed value.
19
+ *
20
+ * - Return a non-null value to transform and store it as the result
21
+ * - Return `null` to keep the previous result unchanged
22
+ * - Return nothing (`void`) to store the raw result as-is
23
+ */
24
+ onResult?: (result: TTSResult) => TOutput | null | void;
25
+ /** Callback when an error occurs */
26
+ onError?: (error: Error) => void;
27
+ /** Callback when progress is reported (0-100) */
28
+ onProgress?: (progress: number, message?: string) => void;
29
+ /** Callback for each stream chunk (ConnectionAdapter mode only) */
30
+ onChunk?: (chunk: StreamChunk) => void;
31
+ }
32
+ /**
33
+ * Return type for the createGenerateSpeech function.
34
+ *
35
+ * @template TOutput - The output type (after optional transform)
36
+ */
37
+ export interface CreateGenerateSpeechReturn<TOutput = TTSResult> {
38
+ /** The TTS result containing audio data, or null */
39
+ readonly result: TOutput | null;
40
+ /** Whether generation is in progress */
41
+ readonly isLoading: boolean;
42
+ /** Current error, if any */
43
+ readonly error: Error | undefined;
44
+ /** Current state of the generation */
45
+ readonly status: GenerationClientState;
46
+ /** Trigger speech generation */
47
+ generate: (input: SpeechGenerateInput) => Promise<void>;
48
+ /** Abort the current generation */
49
+ stop: () => void;
50
+ /** Clear result, error, and return to idle */
51
+ reset: () => void;
52
+ /** Update additional body parameters */
53
+ updateBody: (body: Record<string, any>) => void;
54
+ }
55
+ /**
56
+ * Creates a reactive speech generation (text-to-speech) instance for Svelte 5.
57
+ *
58
+ * @example
59
+ * ```svelte
60
+ * <script>
61
+ * import { createGenerateSpeech, fetchServerSentEvents } from '@tanstack/ai-svelte'
62
+ *
63
+ * const speech = createGenerateSpeech({
64
+ * connection: fetchServerSentEvents('/api/generate/speech'),
65
+ * })
66
+ * </script>
67
+ *
68
+ * <div>
69
+ * <button onclick={() => speech.generate({ text: 'Hello world', voice: 'alloy' })}>
70
+ * Generate Speech
71
+ * </button>
72
+ * {#if speech.isLoading}
73
+ * <p>Generating...</p>
74
+ * {/if}
75
+ * {#if speech.result}
76
+ * <audio src={`data:audio/${speech.result.format};base64,${speech.result.audio}`} controls></audio>
77
+ * {/if}
78
+ * </div>
79
+ * ```
80
+ */
81
+ export declare function createGenerateSpeech<TOnResult extends ((result: TTSResult) => any) | undefined = undefined>(options: Omit<CreateGenerateSpeechOptions, 'onResult'> & {
82
+ onResult?: TOnResult;
83
+ }): CreateGenerateSpeechReturn<InferGenerationOutput<TTSResult, TOnResult>>;
@@ -0,0 +1,48 @@
1
+ import { createGeneration } from './create-generation.svelte';
2
+ /**
3
+ * Creates a reactive speech generation (text-to-speech) instance for Svelte 5.
4
+ *
5
+ * @example
6
+ * ```svelte
7
+ * <script>
8
+ * import { createGenerateSpeech, fetchServerSentEvents } from '@tanstack/ai-svelte'
9
+ *
10
+ * const speech = createGenerateSpeech({
11
+ * connection: fetchServerSentEvents('/api/generate/speech'),
12
+ * })
13
+ * </script>
14
+ *
15
+ * <div>
16
+ * <button onclick={() => speech.generate({ text: 'Hello world', voice: 'alloy' })}>
17
+ * Generate Speech
18
+ * </button>
19
+ * {#if speech.isLoading}
20
+ * <p>Generating...</p>
21
+ * {/if}
22
+ * {#if speech.result}
23
+ * <audio src={`data:audio/${speech.result.format};base64,${speech.result.audio}`} controls></audio>
24
+ * {/if}
25
+ * </div>
26
+ * ```
27
+ */
28
+ export function createGenerateSpeech(options) {
29
+ const gen = createGeneration(options);
30
+ return {
31
+ get result() {
32
+ return gen.result;
33
+ },
34
+ get isLoading() {
35
+ return gen.isLoading;
36
+ },
37
+ get error() {
38
+ return gen.error;
39
+ },
40
+ get status() {
41
+ return gen.status;
42
+ },
43
+ generate: gen.generate,
44
+ stop: gen.stop,
45
+ reset: gen.reset,
46
+ updateBody: gen.updateBody,
47
+ };
48
+ }
@@ -0,0 +1,95 @@
1
+ import type { StreamChunk } from '@tanstack/ai';
2
+ import type { ConnectionAdapter, GenerationClientState, GenerationFetcher, InferGenerationOutput, VideoGenerateInput, VideoGenerateResult, VideoStatusInfo } from '@tanstack/ai-client';
3
+ /**
4
+ * Options for the createGenerateVideo function.
5
+ *
6
+ * @template TOutput - The output type after optional transform (defaults to VideoGenerateResult)
7
+ */
8
+ export interface CreateGenerateVideoOptions<TOutput = VideoGenerateResult> {
9
+ /** Connection adapter for streaming transport (server handles polling) */
10
+ connection?: ConnectionAdapter;
11
+ /** Direct async function that returns a completed video result */
12
+ fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>;
13
+ /** Unique identifier for this generation instance */
14
+ id?: string;
15
+ /** Additional body parameters to send with ConnectionAdapter requests */
16
+ body?: Record<string, any>;
17
+ /**
18
+ * Callback when video generation completes. Can optionally return a transformed value.
19
+ *
20
+ * - Return a non-null value to transform and store it as the result
21
+ * - Return `null` to keep the previous result unchanged
22
+ * - Return nothing (`void`) to store the raw result as-is
23
+ */
24
+ onResult?: (result: VideoGenerateResult) => TOutput | null | void;
25
+ /** Callback when an error occurs */
26
+ onError?: (error: Error) => void;
27
+ /** Callback when progress is reported (0-100) */
28
+ onProgress?: (progress: number, message?: string) => void;
29
+ /** Callback when a video job is created */
30
+ onJobCreated?: (jobId: string) => void;
31
+ /** Callback on each status update */
32
+ onStatusUpdate?: (status: VideoStatusInfo) => void;
33
+ /** Callback for each stream chunk (ConnectionAdapter mode only) */
34
+ onChunk?: (chunk: StreamChunk) => void;
35
+ }
36
+ /**
37
+ * Return type for the createGenerateVideo function.
38
+ *
39
+ * @template TOutput - The output type (after optional transform)
40
+ */
41
+ export interface CreateGenerateVideoReturn<TOutput = VideoGenerateResult> {
42
+ /** The final video result (with URL), or null */
43
+ readonly result: TOutput | null;
44
+ /** The current job ID, or null */
45
+ readonly jobId: string | null;
46
+ /** Current video generation status info, or null */
47
+ readonly videoStatus: VideoStatusInfo | null;
48
+ /** Whether generation/polling is in progress */
49
+ readonly isLoading: boolean;
50
+ /** Current error, if any */
51
+ readonly error: Error | undefined;
52
+ /** Current state of the generation */
53
+ readonly status: GenerationClientState;
54
+ /** Trigger video generation */
55
+ generate: (input: VideoGenerateInput) => Promise<void>;
56
+ /** Abort the current generation/polling */
57
+ stop: () => void;
58
+ /** Clear all state and return to idle */
59
+ reset: () => void;
60
+ /** Update additional body parameters */
61
+ updateBody: (body: Record<string, any>) => void;
62
+ }
63
+ /**
64
+ * Creates a reactive video generation instance for Svelte 5.
65
+ *
66
+ * Video generation is asynchronous: a job is created, then polled for status
67
+ * until completion. This function handles the full lifecycle.
68
+ *
69
+ * @example
70
+ * ```svelte
71
+ * <script>
72
+ * import { createGenerateVideo, fetchServerSentEvents } from '@tanstack/ai-svelte'
73
+ *
74
+ * const video = createGenerateVideo({
75
+ * connection: fetchServerSentEvents('/api/generate/video'),
76
+ * onStatusUpdate: (status) => console.log(`Progress: ${status.progress}%`),
77
+ * })
78
+ * </script>
79
+ *
80
+ * <div>
81
+ * <button onclick={() => video.generate({ prompt: 'A flying car over a city' })}>
82
+ * Generate Video
83
+ * </button>
84
+ * {#if video.isLoading && video.videoStatus}
85
+ * <p>Status: {video.videoStatus.status} ({video.videoStatus.progress}%)</p>
86
+ * {/if}
87
+ * {#if video.result}
88
+ * <video src={video.result.url} controls></video>
89
+ * {/if}
90
+ * </div>
91
+ * ```
92
+ */
93
+ export declare function createGenerateVideo<TOnResult extends ((result: VideoGenerateResult) => any) | undefined = undefined>(options: Omit<CreateGenerateVideoOptions, 'onResult'> & {
94
+ onResult?: TOnResult;
95
+ }): CreateGenerateVideoReturn<InferGenerationOutput<VideoGenerateResult, TOnResult>>;
@@ -0,0 +1,126 @@
1
+ import { VideoGenerationClient } from '@tanstack/ai-client';
2
+ /**
3
+ * Creates a reactive video generation instance for Svelte 5.
4
+ *
5
+ * Video generation is asynchronous: a job is created, then polled for status
6
+ * until completion. This function handles the full lifecycle.
7
+ *
8
+ * @example
9
+ * ```svelte
10
+ * <script>
11
+ * import { createGenerateVideo, fetchServerSentEvents } from '@tanstack/ai-svelte'
12
+ *
13
+ * const video = createGenerateVideo({
14
+ * connection: fetchServerSentEvents('/api/generate/video'),
15
+ * onStatusUpdate: (status) => console.log(`Progress: ${status.progress}%`),
16
+ * })
17
+ * </script>
18
+ *
19
+ * <div>
20
+ * <button onclick={() => video.generate({ prompt: 'A flying car over a city' })}>
21
+ * Generate Video
22
+ * </button>
23
+ * {#if video.isLoading && video.videoStatus}
24
+ * <p>Status: {video.videoStatus.status} ({video.videoStatus.progress}%)</p>
25
+ * {/if}
26
+ * {#if video.result}
27
+ * <video src={video.result.url} controls></video>
28
+ * {/if}
29
+ * </div>
30
+ * ```
31
+ */
32
+ export function createGenerateVideo(options) {
33
+ const clientId = options.id ||
34
+ `video-${Date.now()}-${Math.random().toString(36).substring(7)}`;
35
+ // Create reactive state using Svelte 5 runes
36
+ let result = $state(null);
37
+ let jobId = $state(null);
38
+ let videoStatus = $state(null);
39
+ let isLoading = $state(false);
40
+ let error = $state(undefined);
41
+ let status = $state('idle');
42
+ const baseOptions = {
43
+ id: clientId,
44
+ body: options.body,
45
+ onResult: (r) => options.onResult?.(r),
46
+ onError: (e) => options.onError?.(e),
47
+ onProgress: (p, m) => options.onProgress?.(p, m),
48
+ onChunk: (c) => options.onChunk?.(c),
49
+ onJobCreated: (id) => options.onJobCreated?.(id),
50
+ onStatusUpdate: (s) => options.onStatusUpdate?.(s),
51
+ onResultChange: (r) => {
52
+ result = r;
53
+ },
54
+ onLoadingChange: (l) => {
55
+ isLoading = l;
56
+ },
57
+ onErrorChange: (e) => {
58
+ error = e;
59
+ },
60
+ onStatusChange: (s) => {
61
+ status = s;
62
+ },
63
+ onJobIdChange: (id) => {
64
+ jobId = id;
65
+ },
66
+ onVideoStatusChange: (s) => {
67
+ videoStatus = s;
68
+ },
69
+ };
70
+ let client;
71
+ if (options.connection) {
72
+ client = new VideoGenerationClient({
73
+ ...baseOptions,
74
+ connection: options.connection,
75
+ });
76
+ }
77
+ else if (options.fetcher) {
78
+ client = new VideoGenerationClient({
79
+ ...baseOptions,
80
+ fetcher: options.fetcher,
81
+ });
82
+ }
83
+ else {
84
+ throw new Error('createGenerateVideo requires either a connection or fetcher option');
85
+ }
86
+ // Note: Cleanup is handled by calling stop() directly when needed.
87
+ // Unlike React/Vue/Solid, Svelte 5 runes like $effect can only be used
88
+ // during component initialization, so we don't add automatic cleanup here.
89
+ // Users should call video.stop() in their component's cleanup if needed.
90
+ const generate = async (input) => {
91
+ await client.generate(input);
92
+ };
93
+ const stop = () => {
94
+ client.stop();
95
+ };
96
+ const reset = () => {
97
+ client.reset();
98
+ };
99
+ const updateBody = (newBody) => {
100
+ client.updateOptions({ body: newBody });
101
+ };
102
+ return {
103
+ get result() {
104
+ return result;
105
+ },
106
+ get jobId() {
107
+ return jobId;
108
+ },
109
+ get videoStatus() {
110
+ return videoStatus;
111
+ },
112
+ get isLoading() {
113
+ return isLoading;
114
+ },
115
+ get error() {
116
+ return error;
117
+ },
118
+ get status() {
119
+ return status;
120
+ },
121
+ generate,
122
+ stop,
123
+ reset,
124
+ updateBody,
125
+ };
126
+ }
@@ -0,0 +1,92 @@
1
+ import type { StreamChunk } from '@tanstack/ai';
2
+ import type { ConnectionAdapter, GenerationClientState, GenerationFetcher, InferGenerationOutput } from '@tanstack/ai-client';
3
+ /**
4
+ * Options for the createGeneration function.
5
+ *
6
+ * Accepts either a `connection` (streaming transport) or a `fetcher` (direct async call).
7
+ *
8
+ * @template TInput - The input type for the generation request
9
+ * @template TResult - The result type returned by the generation
10
+ * @template TOutput - The output type after optional transform (defaults to TResult)
11
+ */
12
+ export interface CreateGenerationOptions<TInput, TResult, TOutput = TResult> {
13
+ /** Connection adapter for streaming transport (SSE, HTTP stream, custom) */
14
+ connection?: ConnectionAdapter;
15
+ /** Direct async function for one-shot generation (no streaming protocol needed) */
16
+ fetcher?: GenerationFetcher<TInput, TResult>;
17
+ /** Unique identifier for this generation instance */
18
+ id?: string;
19
+ /** Additional body parameters to send with ConnectionAdapter requests */
20
+ body?: Record<string, any>;
21
+ /**
22
+ * Callback when a result is received. Can optionally return a transformed value.
23
+ *
24
+ * - Return a non-null value to transform and store it as the result
25
+ * - Return `null` to keep the previous result unchanged
26
+ * - Return nothing (`void`) to store the raw result as-is
27
+ */
28
+ onResult?: (result: TResult) => TOutput | null | void;
29
+ /** Callback when an error occurs */
30
+ onError?: (error: Error) => void;
31
+ /** Callback when progress is reported (0-100) */
32
+ onProgress?: (progress: number, message?: string) => void;
33
+ /** Callback for each stream chunk (ConnectionAdapter mode only) */
34
+ onChunk?: (chunk: StreamChunk) => void;
35
+ }
36
+ /**
37
+ * Return type for the createGeneration function.
38
+ *
39
+ * @template TOutput - The output type (after optional transform)
40
+ */
41
+ export interface CreateGenerationReturn<TOutput> {
42
+ /** The generation result, or null if not yet generated */
43
+ readonly result: TOutput | null;
44
+ /** Whether a generation is currently in progress */
45
+ readonly isLoading: boolean;
46
+ /** Current error, if any */
47
+ readonly error: Error | undefined;
48
+ /** Current state of the generation client */
49
+ readonly status: GenerationClientState;
50
+ /** Trigger a generation request */
51
+ generate: (input: Record<string, any>) => Promise<void>;
52
+ /** Abort the current generation */
53
+ stop: () => void;
54
+ /** Clear result, error, and return to idle */
55
+ reset: () => void;
56
+ /** Update additional body parameters */
57
+ updateBody: (body: Record<string, any>) => void;
58
+ }
59
+ /**
60
+ * Creates a reactive generation instance for Svelte 5.
61
+ *
62
+ * This is the base function used by `createGenerateImage`, `createGenerateSpeech`,
63
+ * `createTranscription`, and `createSummarize`. You can also use it directly
64
+ * for custom generation types.
65
+ *
66
+ * @template TInput - The input type for the generation request
67
+ * @template TResult - The result type returned by the generation
68
+ *
69
+ * @example
70
+ * ```svelte
71
+ * <script>
72
+ * import { createGeneration, fetchServerSentEvents } from '@tanstack/ai-svelte'
73
+ *
74
+ * const gen = createGeneration({
75
+ * connection: fetchServerSentEvents('/api/generate/custom'),
76
+ * })
77
+ * </script>
78
+ *
79
+ * <div>
80
+ * <button onclick={() => gen.generate({ prompt: 'Hello' })}>Generate</button>
81
+ * {#if gen.isLoading}
82
+ * <p>Generating...</p>
83
+ * {/if}
84
+ * {#if gen.result}
85
+ * <p>{JSON.stringify(gen.result)}</p>
86
+ * {/if}
87
+ * </div>
88
+ * ```
89
+ */
90
+ export declare function createGeneration<TInput extends Record<string, any>, TResult, TOnResult extends ((result: TResult) => any) | undefined = undefined>(options: Omit<CreateGenerationOptions<TInput, TResult>, 'onResult'> & {
91
+ onResult?: TOnResult;
92
+ }): CreateGenerationReturn<InferGenerationOutput<TResult, TOnResult>>;