@tanstack/ai-angular 0.0.1
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.
- package/README.md +158 -0
- package/dist/README.md +158 -0
- package/dist/fesm2022/tanstack-ai-angular.mjs +478 -0
- package/dist/fesm2022/tanstack-ai-angular.mjs.map +1 -0
- package/dist/types/tanstack-ai-angular.d.ts +324 -0
- package/package.json +83 -0
- package/src/index.ts +89 -0
- package/src/inject-chat.ts +255 -0
- package/src/inject-generate-audio.ts +130 -0
- package/src/inject-generate-image.ts +58 -0
- package/src/inject-generate-speech.ts +55 -0
- package/src/inject-generate-video.ts +147 -0
- package/src/inject-generation.ts +155 -0
- package/src/inject-summarize.ts +58 -0
- package/src/inject-transcription.ts +66 -0
- package/src/internal/to-reactive.ts +26 -0
- package/src/types.ts +141 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { AnyClientTool, SchemaInput, ModelMessage, InferSchemaType, StreamChunk, ImageGenerationResult, AudioGenerationResult, TTSResult, TranscriptionResult, SummarizationResult } from '@tanstack/ai';
|
|
2
|
+
import { InferredClientContext, DistributedOmit, ChatClientOptions, AIDevtoolsDisplayOptions, ClientContextOptionFromTools, UIMessage, MultimodalContent, ChatClientState, ConnectionStatus, ConnectConnectionAdapter, GenerationFetcher, GenerationClientState, InferGenerationOutput, ImageGenerateInput, AudioGenerateInput, SpeechGenerateInput, TranscriptionGenerateInput, SummarizeGenerateInput, VideoGenerateResult, VideoGenerateInput, VideoStatusInfo } from '@tanstack/ai-client';
|
|
3
|
+
export { AudioGenerateInput, ChatRequestBody, ConnectConnectionAdapter, ConnectionAdapter, FetchConnectionOptions, GenerationClientState, ImageGenerateInput, InferChatMessages, MultimodalContent, RunAgentInputContext, SpeechGenerateInput, SubscribeConnectionAdapter, SummarizeGenerateInput, TranscriptionGenerateInput, UIMessage, VideoGenerateInput, VideoGenerateResult, VideoStatusInfo, XhrConnectionOptions, createChatClientOptions, fetchHttpStream, fetchServerSentEvents, rpcStream, stream, xhrHttpStream, xhrServerSentEvents } from '@tanstack/ai-client';
|
|
4
|
+
import { Signal } from '@angular/core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A value that may be supplied to `injectChat` either as a static value, an
|
|
8
|
+
* Angular `Signal`, or a zero-arg getter. The getter form lets callers read
|
|
9
|
+
* other signals so the option stays reactive.
|
|
10
|
+
*/
|
|
11
|
+
type ReactiveOption<T> = T | Signal<T> | (() => T);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Recursive partial — every property and every nested array element is optional.
|
|
15
|
+
* Used to type the in-flight `partial` value while a structured-output stream
|
|
16
|
+
* is still arriving.
|
|
17
|
+
*/
|
|
18
|
+
type DeepPartial<T> = T extends ReadonlyArray<infer U> ? Array<DeepPartial<U>> : T extends object ? {
|
|
19
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
20
|
+
} : T;
|
|
21
|
+
/**
|
|
22
|
+
* Options for {@link injectChat}.
|
|
23
|
+
*
|
|
24
|
+
* Mirrors the Vue `useChat` options, except:
|
|
25
|
+
* - State-change callbacks are managed internally and exposed as signals.
|
|
26
|
+
* - `body`, `forwardedProps`, and `live` accept a {@link ReactiveOption} so
|
|
27
|
+
* they can be a static value, a `Signal`, or a getter and stay reactive.
|
|
28
|
+
*/
|
|
29
|
+
type InjectChatOptions<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TContext = InferredClientContext<TTools>> = DistributedOmit<ChatClientOptions<TTools, TContext>, 'onMessagesChange' | 'onLoadingChange' | 'onErrorChange' | 'onStatusChange' | 'onSubscriptionChange' | 'onConnectionStatusChange' | 'onSessionGeneratingChange' | 'context' | 'devtools' | 'body' | 'forwardedProps'> & {
|
|
30
|
+
/** Display options for TanStack AI Devtools. */
|
|
31
|
+
devtools?: AIDevtoolsDisplayOptions;
|
|
32
|
+
/** Additional request body params. Reactive. */
|
|
33
|
+
body?: ReactiveOption<Record<string, any>>;
|
|
34
|
+
/** Forwarded request props (preferred over `body`). Reactive. */
|
|
35
|
+
forwardedProps?: ReactiveOption<Record<string, any>>;
|
|
36
|
+
/** Whether to keep a live subscription open. Reactive. */
|
|
37
|
+
live?: ReactiveOption<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Standard-schema-compatible schema (Zod, Valibot, ArkType, or JSON Schema).
|
|
40
|
+
* Used to infer the shape of `partial` and `final`.
|
|
41
|
+
*/
|
|
42
|
+
outputSchema?: TSchema;
|
|
43
|
+
} & ClientContextOptionFromTools<TTools, ReactiveOption<TContext>>;
|
|
44
|
+
/**
|
|
45
|
+
* Return shape of {@link injectChat}. When `outputSchema` is supplied, adds
|
|
46
|
+
* typed `partial` / `final` signals; otherwise the return is unchanged.
|
|
47
|
+
*/
|
|
48
|
+
type InjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined> = BaseInjectChatResult<TTools, TSchema extends SchemaInput ? InferSchemaType<TSchema> : unknown> & (TSchema extends SchemaInput ? {
|
|
49
|
+
/** Live progressively-parsed structured output. */
|
|
50
|
+
partial: Signal<DeepPartial<InferSchemaType<TSchema>>>;
|
|
51
|
+
/** Final, schema-validated structured output. `null` until complete. */
|
|
52
|
+
final: Signal<InferSchemaType<TSchema> | null>;
|
|
53
|
+
} : Record<never, never>);
|
|
54
|
+
interface BaseInjectChatResult<TTools extends ReadonlyArray<AnyClientTool> = any, TData = unknown> {
|
|
55
|
+
/** Current messages in the conversation. */
|
|
56
|
+
messages: Signal<Array<UIMessage<TTools, TData>>>;
|
|
57
|
+
/** Send a message (string or multimodal content). */
|
|
58
|
+
sendMessage: (content: string | MultimodalContent) => Promise<void>;
|
|
59
|
+
/** Append a message to the conversation. */
|
|
60
|
+
append: (message: ModelMessage | UIMessage<TTools, TData>) => Promise<void>;
|
|
61
|
+
/** Add the result of a client-side tool execution. */
|
|
62
|
+
addToolResult: (result: {
|
|
63
|
+
toolCallId: string;
|
|
64
|
+
tool: string;
|
|
65
|
+
output: any;
|
|
66
|
+
state?: 'output-available' | 'output-error';
|
|
67
|
+
errorText?: string;
|
|
68
|
+
}) => Promise<void>;
|
|
69
|
+
/** Respond to a tool approval request. */
|
|
70
|
+
addToolApprovalResponse: (response: {
|
|
71
|
+
id: string;
|
|
72
|
+
approved: boolean;
|
|
73
|
+
}) => Promise<void>;
|
|
74
|
+
/** Reload the last assistant message. */
|
|
75
|
+
reload: () => Promise<void>;
|
|
76
|
+
/** Stop the current response generation. */
|
|
77
|
+
stop: () => void;
|
|
78
|
+
/** Whether a response is currently being generated. */
|
|
79
|
+
isLoading: Signal<boolean>;
|
|
80
|
+
/** Current error, if any. */
|
|
81
|
+
error: Signal<Error | undefined>;
|
|
82
|
+
/** Set messages manually. */
|
|
83
|
+
setMessages: (messages: Array<UIMessage<TTools, TData>>) => void;
|
|
84
|
+
/** Clear all messages. */
|
|
85
|
+
clear: () => void;
|
|
86
|
+
/** Current generation status. */
|
|
87
|
+
status: Signal<ChatClientState>;
|
|
88
|
+
/** Whether the subscription loop is active. */
|
|
89
|
+
isSubscribed: Signal<boolean>;
|
|
90
|
+
/** Current connection lifecycle status. */
|
|
91
|
+
connectionStatus: Signal<ConnectionStatus>;
|
|
92
|
+
/** Whether the shared session is actively generating. */
|
|
93
|
+
sessionGenerating: Signal<boolean>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare function injectChat<TTools extends ReadonlyArray<AnyClientTool> = any, TSchema extends SchemaInput | undefined = undefined, TContext = InferredClientContext<TTools>>(options?: InjectChatOptions<TTools, TSchema, TContext>): InjectChatResult<TTools, TSchema>;
|
|
97
|
+
|
|
98
|
+
interface InjectGenerationOptions<TInput, TResult, TOutput = TResult> {
|
|
99
|
+
/** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */
|
|
100
|
+
connection?: ConnectConnectionAdapter;
|
|
101
|
+
/** Direct async function for one-shot generation (no streaming protocol needed) */
|
|
102
|
+
fetcher?: GenerationFetcher<TInput, TResult>;
|
|
103
|
+
/** Unique identifier for this generation instance */
|
|
104
|
+
id?: string;
|
|
105
|
+
/** Additional request body params. Reactive. */
|
|
106
|
+
body?: ReactiveOption<Record<string, any>>;
|
|
107
|
+
/** Display options for TanStack AI Devtools. */
|
|
108
|
+
devtools?: AIDevtoolsDisplayOptions;
|
|
109
|
+
/**
|
|
110
|
+
* Callback when a result is received. Can optionally return a transformed value.
|
|
111
|
+
*
|
|
112
|
+
* - Return a non-null value to transform and store it as the result
|
|
113
|
+
* - Return `null` to keep the previous result unchanged
|
|
114
|
+
* - Return nothing (`void`) to store the raw result as-is
|
|
115
|
+
*/
|
|
116
|
+
onResult?: (result: TResult) => TOutput | null | void;
|
|
117
|
+
/** Callback when an error occurs */
|
|
118
|
+
onError?: (error: Error) => void;
|
|
119
|
+
/** Callback when progress is reported (0-100) */
|
|
120
|
+
onProgress?: (progress: number, message?: string) => void;
|
|
121
|
+
/** Callback for each stream chunk (connect-based adapter mode only) */
|
|
122
|
+
onChunk?: (chunk: StreamChunk) => void;
|
|
123
|
+
}
|
|
124
|
+
interface InjectGenerationResult<TOutput> {
|
|
125
|
+
/** Trigger a generation request */
|
|
126
|
+
generate: (input: Record<string, any>) => Promise<void>;
|
|
127
|
+
/** The generation result, or null if not yet generated */
|
|
128
|
+
result: Signal<TOutput | null>;
|
|
129
|
+
/** Whether a generation is currently in progress */
|
|
130
|
+
isLoading: Signal<boolean>;
|
|
131
|
+
/** Current error, if any */
|
|
132
|
+
error: Signal<Error | undefined>;
|
|
133
|
+
/** Current state of the generation client */
|
|
134
|
+
status: Signal<GenerationClientState>;
|
|
135
|
+
/** Abort the current generation */
|
|
136
|
+
stop: () => void;
|
|
137
|
+
/** Clear result, error, and return to idle */
|
|
138
|
+
reset: () => void;
|
|
139
|
+
}
|
|
140
|
+
declare function injectGeneration<TInput extends Record<string, any>, TResult, TOnResult extends ((result: TResult) => any) | undefined = undefined>(options: Omit<InjectGenerationOptions<TInput, TResult>, 'onResult'> & {
|
|
141
|
+
onResult?: TOnResult;
|
|
142
|
+
}): InjectGenerationResult<InferGenerationOutput<TResult, TOnResult>>;
|
|
143
|
+
|
|
144
|
+
type InjectGenerateImageOptions<TOutput = ImageGenerationResult> = Omit<InjectGenerationOptions<ImageGenerateInput, ImageGenerationResult, TOutput>, 'onResult'> & {
|
|
145
|
+
onResult?: (result: ImageGenerationResult) => TOutput | null | void;
|
|
146
|
+
};
|
|
147
|
+
interface InjectGenerateImageResult<TOutput = ImageGenerationResult> {
|
|
148
|
+
generate: (input: ImageGenerateInput) => Promise<void>;
|
|
149
|
+
result: Signal<TOutput | null>;
|
|
150
|
+
isLoading: Signal<boolean>;
|
|
151
|
+
error: Signal<Error | undefined>;
|
|
152
|
+
status: Signal<GenerationClientState>;
|
|
153
|
+
stop: () => void;
|
|
154
|
+
reset: () => void;
|
|
155
|
+
}
|
|
156
|
+
declare function injectGenerateImage<TOnResult extends ((result: ImageGenerationResult) => any) | undefined = undefined>(options: Omit<InjectGenerateImageOptions, 'onResult'> & {
|
|
157
|
+
onResult?: TOnResult;
|
|
158
|
+
}): InjectGenerateImageResult<InferGenerationOutput<ImageGenerationResult, TOnResult>>;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Options for the injectGenerateAudio injectable.
|
|
162
|
+
*
|
|
163
|
+
* @template TOutput - The output type after optional transform (defaults to AudioGenerationResult)
|
|
164
|
+
*/
|
|
165
|
+
interface InjectGenerateAudioOptions<TOutput = AudioGenerationResult> {
|
|
166
|
+
/** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */
|
|
167
|
+
connection?: ConnectConnectionAdapter;
|
|
168
|
+
/** Direct async function for audio generation */
|
|
169
|
+
fetcher?: GenerationFetcher<AudioGenerateInput, AudioGenerationResult>;
|
|
170
|
+
/** Unique identifier for this generation instance */
|
|
171
|
+
id?: string;
|
|
172
|
+
/** Additional body parameters to send with connect-based adapter requests. Reactive. */
|
|
173
|
+
body?: ReactiveOption<Record<string, any>>;
|
|
174
|
+
/** Display options for TanStack AI Devtools. */
|
|
175
|
+
devtools?: AIDevtoolsDisplayOptions;
|
|
176
|
+
/**
|
|
177
|
+
* Callback when audio is generated. Can optionally return a transformed value.
|
|
178
|
+
*
|
|
179
|
+
* - Return a non-null value to transform and store it as the result
|
|
180
|
+
* - Return `null` to keep the previous result unchanged
|
|
181
|
+
* - Return nothing (`void`) to store the raw result as-is
|
|
182
|
+
*/
|
|
183
|
+
onResult?: (result: AudioGenerationResult) => TOutput | null | void;
|
|
184
|
+
/** Callback when an error occurs */
|
|
185
|
+
onError?: (error: Error) => void;
|
|
186
|
+
/** Callback when progress is reported (0-100) */
|
|
187
|
+
onProgress?: (progress: number, message?: string) => void;
|
|
188
|
+
/** Callback for each stream chunk (connect-based adapter mode only) */
|
|
189
|
+
onChunk?: (chunk: StreamChunk) => void;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Return type for the injectGenerateAudio injectable.
|
|
193
|
+
*
|
|
194
|
+
* @template TOutput - The output type (after optional transform)
|
|
195
|
+
*/
|
|
196
|
+
interface InjectGenerateAudioResult<TOutput = AudioGenerationResult> {
|
|
197
|
+
/** Trigger audio generation */
|
|
198
|
+
generate: (input: AudioGenerateInput) => Promise<void>;
|
|
199
|
+
/** The generation result containing audio, or null */
|
|
200
|
+
result: Signal<TOutput | null>;
|
|
201
|
+
/** Whether generation is in progress */
|
|
202
|
+
isLoading: Signal<boolean>;
|
|
203
|
+
/** Current error, if any */
|
|
204
|
+
error: Signal<Error | undefined>;
|
|
205
|
+
/** Current state of the generation */
|
|
206
|
+
status: Signal<GenerationClientState>;
|
|
207
|
+
/** Abort the current generation */
|
|
208
|
+
stop: () => void;
|
|
209
|
+
/** Clear result, error, and return to idle */
|
|
210
|
+
reset: () => void;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Angular injectable for generating audio (music, sound effects) using AI models.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* import { Component } from '@angular/core'
|
|
218
|
+
* import { injectGenerateAudio } from '@tanstack/ai-angular'
|
|
219
|
+
* import { fetchServerSentEvents } from '@tanstack/ai-client'
|
|
220
|
+
*
|
|
221
|
+
* @Component({
|
|
222
|
+
* selector: 'app-audio',
|
|
223
|
+
* template: `
|
|
224
|
+
* <button (click)="generate({ prompt: 'An upbeat electronic track', duration: 10 })">
|
|
225
|
+
* Generate
|
|
226
|
+
* </button>
|
|
227
|
+
* @if (result()) {
|
|
228
|
+
* <audio [src]="result()!.audio.url" controls></audio>
|
|
229
|
+
* }
|
|
230
|
+
* `,
|
|
231
|
+
* })
|
|
232
|
+
* export class AudioComponent {
|
|
233
|
+
* private gen = injectGenerateAudio({
|
|
234
|
+
* connection: fetchServerSentEvents('/api/generate/audio'),
|
|
235
|
+
* })
|
|
236
|
+
*
|
|
237
|
+
* generate = this.gen.generate
|
|
238
|
+
* result = this.gen.result
|
|
239
|
+
* isLoading = this.gen.isLoading
|
|
240
|
+
* }
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
declare function injectGenerateAudio<TOnResult extends ((result: AudioGenerationResult) => any) | undefined = undefined>(options: Omit<InjectGenerateAudioOptions, 'onResult'> & {
|
|
244
|
+
onResult?: TOnResult;
|
|
245
|
+
}): InjectGenerateAudioResult<InferGenerationOutput<AudioGenerationResult, TOnResult>>;
|
|
246
|
+
|
|
247
|
+
type InjectGenerateSpeechOptions<TOutput = TTSResult> = Omit<InjectGenerationOptions<SpeechGenerateInput, TTSResult, TOutput>, 'onResult'> & {
|
|
248
|
+
onResult?: (result: TTSResult) => TOutput | null | void;
|
|
249
|
+
};
|
|
250
|
+
interface InjectGenerateSpeechResult<TOutput = TTSResult> {
|
|
251
|
+
generate: (input: SpeechGenerateInput) => Promise<void>;
|
|
252
|
+
result: Signal<TOutput | null>;
|
|
253
|
+
isLoading: Signal<boolean>;
|
|
254
|
+
error: Signal<Error | undefined>;
|
|
255
|
+
status: Signal<GenerationClientState>;
|
|
256
|
+
stop: () => void;
|
|
257
|
+
reset: () => void;
|
|
258
|
+
}
|
|
259
|
+
declare function injectGenerateSpeech<TOnResult extends ((result: TTSResult) => any) | undefined = undefined>(options: Omit<InjectGenerateSpeechOptions, 'onResult'> & {
|
|
260
|
+
onResult?: TOnResult;
|
|
261
|
+
}): InjectGenerateSpeechResult<InferGenerationOutput<TTSResult, TOnResult>>;
|
|
262
|
+
|
|
263
|
+
type InjectTranscriptionOptions<TOutput = TranscriptionResult> = Omit<InjectGenerationOptions<TranscriptionGenerateInput, TranscriptionResult, TOutput>, 'onResult'> & {
|
|
264
|
+
onResult?: (result: TranscriptionResult) => TOutput | null | void;
|
|
265
|
+
};
|
|
266
|
+
interface InjectTranscriptionResult<TOutput = TranscriptionResult> {
|
|
267
|
+
generate: (input: TranscriptionGenerateInput) => Promise<void>;
|
|
268
|
+
result: Signal<TOutput | null>;
|
|
269
|
+
isLoading: Signal<boolean>;
|
|
270
|
+
error: Signal<Error | undefined>;
|
|
271
|
+
status: Signal<GenerationClientState>;
|
|
272
|
+
stop: () => void;
|
|
273
|
+
reset: () => void;
|
|
274
|
+
}
|
|
275
|
+
declare function injectTranscription<TOnResult extends ((result: TranscriptionResult) => any) | undefined = undefined>(options: Omit<InjectTranscriptionOptions, 'onResult'> & {
|
|
276
|
+
onResult?: TOnResult;
|
|
277
|
+
}): InjectTranscriptionResult<InferGenerationOutput<TranscriptionResult, TOnResult>>;
|
|
278
|
+
|
|
279
|
+
type InjectSummarizeOptions<TOutput = SummarizationResult> = Omit<InjectGenerationOptions<SummarizeGenerateInput, SummarizationResult, TOutput>, 'onResult'> & {
|
|
280
|
+
onResult?: (result: SummarizationResult) => TOutput | null | void;
|
|
281
|
+
};
|
|
282
|
+
interface InjectSummarizeResult<TOutput = SummarizationResult> {
|
|
283
|
+
generate: (input: SummarizeGenerateInput) => Promise<void>;
|
|
284
|
+
result: Signal<TOutput | null>;
|
|
285
|
+
isLoading: Signal<boolean>;
|
|
286
|
+
error: Signal<Error | undefined>;
|
|
287
|
+
status: Signal<GenerationClientState>;
|
|
288
|
+
stop: () => void;
|
|
289
|
+
reset: () => void;
|
|
290
|
+
}
|
|
291
|
+
declare function injectSummarize<TOnResult extends ((result: SummarizationResult) => any) | undefined = undefined>(options: Omit<InjectSummarizeOptions, 'onResult'> & {
|
|
292
|
+
onResult?: TOnResult;
|
|
293
|
+
}): InjectSummarizeResult<InferGenerationOutput<SummarizationResult, TOnResult>>;
|
|
294
|
+
|
|
295
|
+
interface InjectGenerateVideoOptions<TOutput = VideoGenerateResult> {
|
|
296
|
+
connection?: ConnectConnectionAdapter;
|
|
297
|
+
fetcher?: GenerationFetcher<VideoGenerateInput, VideoGenerateResult>;
|
|
298
|
+
id?: string;
|
|
299
|
+
body?: ReactiveOption<Record<string, any>>;
|
|
300
|
+
devtools?: AIDevtoolsDisplayOptions;
|
|
301
|
+
onResult?: (result: VideoGenerateResult) => TOutput | null | void;
|
|
302
|
+
onError?: (error: Error) => void;
|
|
303
|
+
onProgress?: (progress: number, message?: string) => void;
|
|
304
|
+
onJobCreated?: (jobId: string) => void;
|
|
305
|
+
onStatusUpdate?: (status: VideoStatusInfo) => void;
|
|
306
|
+
onChunk?: (chunk: StreamChunk) => void;
|
|
307
|
+
}
|
|
308
|
+
interface InjectGenerateVideoResult<TOutput = VideoGenerateResult> {
|
|
309
|
+
generate: (input: VideoGenerateInput) => Promise<void>;
|
|
310
|
+
result: Signal<TOutput | null>;
|
|
311
|
+
jobId: Signal<string | null>;
|
|
312
|
+
videoStatus: Signal<VideoStatusInfo | null>;
|
|
313
|
+
isLoading: Signal<boolean>;
|
|
314
|
+
error: Signal<Error | undefined>;
|
|
315
|
+
status: Signal<GenerationClientState>;
|
|
316
|
+
stop: () => void;
|
|
317
|
+
reset: () => void;
|
|
318
|
+
}
|
|
319
|
+
declare function injectGenerateVideo<TOnResult extends ((result: VideoGenerateResult) => any) | undefined = undefined>(options: Omit<InjectGenerateVideoOptions, 'onResult'> & {
|
|
320
|
+
onResult?: TOnResult;
|
|
321
|
+
}): InjectGenerateVideoResult<InferGenerationOutput<VideoGenerateResult, TOnResult>>;
|
|
322
|
+
|
|
323
|
+
export { injectChat, injectGenerateAudio, injectGenerateImage, injectGenerateSpeech, injectGenerateVideo, injectGeneration, injectSummarize, injectTranscription };
|
|
324
|
+
export type { DeepPartial, InjectChatOptions, InjectChatResult, InjectGenerateAudioOptions, InjectGenerateAudioResult, InjectGenerateImageOptions, InjectGenerateImageResult, InjectGenerateSpeechOptions, InjectGenerateSpeechResult, InjectGenerateVideoOptions, InjectGenerateVideoResult, InjectGenerationOptions, InjectGenerationResult, InjectSummarizeOptions, InjectSummarizeResult, InjectTranscriptionOptions, InjectTranscriptionResult, ReactiveOption };
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tanstack/ai-angular",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Angular signals integration for TanStack AI streaming chat, structured outputs, and media generation.",
|
|
5
|
+
"author": "",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/TanStack/ai.git",
|
|
10
|
+
"directory": "packages/ai-angular"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://tanstack.com/ai",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"ai",
|
|
15
|
+
"ai-sdk",
|
|
16
|
+
"typescript",
|
|
17
|
+
"tanstack",
|
|
18
|
+
"angular",
|
|
19
|
+
"signals",
|
|
20
|
+
"chat",
|
|
21
|
+
"streaming",
|
|
22
|
+
"tool-calling",
|
|
23
|
+
"structured-outputs",
|
|
24
|
+
"media-generation"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"type": "module",
|
|
30
|
+
"module": "dist/fesm2022/tanstack-ai-angular.mjs",
|
|
31
|
+
"types": "./dist/types/tanstack-ai-angular.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/types/tanstack-ai-angular.d.ts",
|
|
35
|
+
"default": "./dist/fesm2022/tanstack-ai-angular.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": {
|
|
38
|
+
"default": "./package.json"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist",
|
|
47
|
+
"src"
|
|
48
|
+
],
|
|
49
|
+
"scripts": {
|
|
50
|
+
"clean": "premove ./build ./dist",
|
|
51
|
+
"test:eslint": "eslint ./src",
|
|
52
|
+
"test:lib": "vitest run",
|
|
53
|
+
"test:lib:dev": "vitest",
|
|
54
|
+
"test:types": "tsc",
|
|
55
|
+
"test:build": "publint --strict",
|
|
56
|
+
"build": "ng-packagr -p ng-package.json -c tsconfig.build.json && rm -rf ./dist/package.json"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@tanstack/ai-client": "workspace:*",
|
|
60
|
+
"tslib": "^2.8.1"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@angular/core": ">=21.0.0",
|
|
64
|
+
"@tanstack/ai": "workspace:^"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@analogjs/vite-plugin-angular": "^1.10.0",
|
|
68
|
+
"@angular/build": "^21.2.0",
|
|
69
|
+
"@angular/common": "^21.2.0",
|
|
70
|
+
"@angular/compiler": "^21.2.0",
|
|
71
|
+
"@angular/core": "^21.2.0",
|
|
72
|
+
"@angular/platform-browser": "^21.2.0",
|
|
73
|
+
"@angular/platform-browser-dynamic": "^21.2.0",
|
|
74
|
+
"@tanstack/ai": "workspace:*",
|
|
75
|
+
"@types/node": "^24.10.1",
|
|
76
|
+
"jsdom": "^27.2.0",
|
|
77
|
+
"ng-packagr": "^21.2.0",
|
|
78
|
+
"typescript": "5.9.3",
|
|
79
|
+
"vitest": "^4.0.14",
|
|
80
|
+
"zod": "^4.2.0",
|
|
81
|
+
"zone.js": "^0.15.0"
|
|
82
|
+
}
|
|
83
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Chat
|
|
2
|
+
export { injectChat } from './inject-chat'
|
|
3
|
+
|
|
4
|
+
// Generation
|
|
5
|
+
export { injectGeneration } from './inject-generation'
|
|
6
|
+
export type {
|
|
7
|
+
InjectGenerationOptions,
|
|
8
|
+
InjectGenerationResult,
|
|
9
|
+
} from './inject-generation'
|
|
10
|
+
|
|
11
|
+
// Generate Image
|
|
12
|
+
export { injectGenerateImage } from './inject-generate-image'
|
|
13
|
+
export type {
|
|
14
|
+
InjectGenerateImageOptions,
|
|
15
|
+
InjectGenerateImageResult,
|
|
16
|
+
} from './inject-generate-image'
|
|
17
|
+
|
|
18
|
+
// Generate Audio
|
|
19
|
+
export { injectGenerateAudio } from './inject-generate-audio'
|
|
20
|
+
export type {
|
|
21
|
+
InjectGenerateAudioOptions,
|
|
22
|
+
InjectGenerateAudioResult,
|
|
23
|
+
} from './inject-generate-audio'
|
|
24
|
+
|
|
25
|
+
// Generate Speech
|
|
26
|
+
export { injectGenerateSpeech } from './inject-generate-speech'
|
|
27
|
+
export type {
|
|
28
|
+
InjectGenerateSpeechOptions,
|
|
29
|
+
InjectGenerateSpeechResult,
|
|
30
|
+
} from './inject-generate-speech'
|
|
31
|
+
|
|
32
|
+
// Transcription
|
|
33
|
+
export { injectTranscription } from './inject-transcription'
|
|
34
|
+
export type {
|
|
35
|
+
InjectTranscriptionOptions,
|
|
36
|
+
InjectTranscriptionResult,
|
|
37
|
+
} from './inject-transcription'
|
|
38
|
+
|
|
39
|
+
// Summarize
|
|
40
|
+
export { injectSummarize } from './inject-summarize'
|
|
41
|
+
export type {
|
|
42
|
+
InjectSummarizeOptions,
|
|
43
|
+
InjectSummarizeResult,
|
|
44
|
+
} from './inject-summarize'
|
|
45
|
+
|
|
46
|
+
// Generate Video
|
|
47
|
+
export { injectGenerateVideo } from './inject-generate-video'
|
|
48
|
+
export type {
|
|
49
|
+
InjectGenerateVideoOptions,
|
|
50
|
+
InjectGenerateVideoResult,
|
|
51
|
+
} from './inject-generate-video'
|
|
52
|
+
|
|
53
|
+
// Types from ./types
|
|
54
|
+
export type {
|
|
55
|
+
DeepPartial,
|
|
56
|
+
InjectChatOptions,
|
|
57
|
+
InjectChatResult,
|
|
58
|
+
UIMessage,
|
|
59
|
+
ChatRequestBody,
|
|
60
|
+
MultimodalContent,
|
|
61
|
+
ReactiveOption,
|
|
62
|
+
} from './types'
|
|
63
|
+
|
|
64
|
+
// Re-export from @tanstack/ai-client for convenience
|
|
65
|
+
export {
|
|
66
|
+
fetchServerSentEvents,
|
|
67
|
+
fetchHttpStream,
|
|
68
|
+
xhrServerSentEvents,
|
|
69
|
+
xhrHttpStream,
|
|
70
|
+
stream,
|
|
71
|
+
rpcStream,
|
|
72
|
+
createChatClientOptions,
|
|
73
|
+
type ConnectionAdapter,
|
|
74
|
+
type ConnectConnectionAdapter,
|
|
75
|
+
type SubscribeConnectionAdapter,
|
|
76
|
+
type RunAgentInputContext,
|
|
77
|
+
type FetchConnectionOptions,
|
|
78
|
+
type XhrConnectionOptions,
|
|
79
|
+
type InferChatMessages,
|
|
80
|
+
type GenerationClientState,
|
|
81
|
+
type ImageGenerateInput,
|
|
82
|
+
type AudioGenerateInput,
|
|
83
|
+
type SpeechGenerateInput,
|
|
84
|
+
type TranscriptionGenerateInput,
|
|
85
|
+
type SummarizeGenerateInput,
|
|
86
|
+
type VideoGenerateInput,
|
|
87
|
+
type VideoGenerateResult,
|
|
88
|
+
type VideoStatusInfo,
|
|
89
|
+
} from '@tanstack/ai-client'
|