@tanstack/ai-octane 0.9.1 → 1.1.0
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 +36 -28
- package/package.json +7 -7
- package/src/chat-ui/create-chat-hook.tsrx +7 -12
- package/src/chat-ui/create-chat-hook.tsrx.d.ts +64 -14
- package/src/chat-ui/create-ui.tsrx +6 -3
- package/src/chat-ui/create-ui.tsrx.d.ts +204 -58
- package/src/create-chat-hook.ts +26 -11
- package/src/index.ts +6 -2
- package/src/realtime-types.ts +1 -1
- package/src/types.ts +0 -15
- package/src/use-audio-recorder.tsrx +1 -1
- package/src/use-audio-recorder.tsrx.d.ts +1 -1
- package/src/use-chat.tsrx +8 -41
- package/src/use-generate-3d-model.tsrx +143 -0
- package/src/use-generate-3d-model.tsrx.d.ts +116 -0
- package/src/use-generate-audio.tsrx +3 -2
- package/src/use-generate-audio.tsrx.d.ts +3 -2
- package/src/use-generate-image.tsrx +3 -2
- package/src/use-generate-image.tsrx.d.ts +3 -2
- package/src/use-generate-speech.tsrx +3 -2
- package/src/use-generate-speech.tsrx.d.ts +3 -2
- package/src/use-generate-video.tsrx +6 -6
- package/src/use-generate-video.tsrx.d.ts +3 -2
- package/src/use-generation.tsrx +5 -6
- package/src/use-generation.tsrx.d.ts +2 -2
- package/src/use-summarize.tsrx +3 -2
- package/src/use-summarize.tsrx.d.ts +3 -2
- package/src/use-transcription.tsrx +3 -2
- package/src/use-transcription.tsrx.d.ts +3 -2
- package/src/use-web-mcp-tools.tsrx +1 -10
- package/src/use-web-mcp-tools.tsrx.d.ts +1 -8
package/src/use-generation.tsrx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GenerationClient } from '@tanstack/ai-client'
|
|
2
2
|
import { createGenerationDevtoolsBridge } from '@tanstack/ai-client/devtools'
|
|
3
|
-
import { useCallback, useEffect,
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'octane'
|
|
4
4
|
import type { StreamChunk } from '@tanstack/ai'
|
|
5
5
|
import type {
|
|
6
6
|
AIDevtoolsDisplayOptions,
|
|
@@ -25,8 +25,8 @@ export interface UseGenerationOptions<TInput, TResult, TOutput = TResult> {
|
|
|
25
25
|
connection?: ConnectConnectionAdapter
|
|
26
26
|
/** Direct async function for one-shot generation (no streaming protocol needed) */
|
|
27
27
|
fetcher?: GenerationFetcher<TInput, TResult>
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/** Stable scope for this generation. Also the wire and DevTools identity. */
|
|
29
|
+
threadId: string
|
|
30
30
|
/** Additional body parameters to send with connect-based adapter requests */
|
|
31
31
|
body?: Record<string, any>
|
|
32
32
|
/** Display options for TanStack AI Devtools. */
|
|
@@ -114,8 +114,7 @@ export function useGeneration<
|
|
|
114
114
|
InferGenerationOutputFromReturn<TResult, TTransformed>
|
|
115
115
|
> {
|
|
116
116
|
type TOutput = InferGenerationOutputFromReturn<TResult, TTransformed>
|
|
117
|
-
const
|
|
118
|
-
const clientId = options.id || hookId
|
|
117
|
+
const clientId = options.threadId
|
|
119
118
|
|
|
120
119
|
const [result, setResult] = useState<TOutput | null>(null)
|
|
121
120
|
const [isLoading, setIsLoading] = useState(false)
|
|
@@ -133,7 +132,7 @@ export function useGeneration<
|
|
|
133
132
|
// wrap optional ones in non-returning bodies so `?.()`'s
|
|
134
133
|
// implicit `undefined` doesn't pollute the function return type.
|
|
135
134
|
const clientOptions: GenerationClientOptions<TInput, TResult, TOutput> = {
|
|
136
|
-
|
|
135
|
+
threadId: clientId,
|
|
137
136
|
body: opts.body,
|
|
138
137
|
devtoolsBridgeFactory: createGenerationDevtoolsBridge,
|
|
139
138
|
devtools: {
|
|
@@ -21,8 +21,8 @@ export interface UseGenerationOptions<TInput, TResult, TOutput = TResult> {
|
|
|
21
21
|
connection?: ConnectConnectionAdapter
|
|
22
22
|
/** Direct async function for one-shot generation (no streaming protocol needed) */
|
|
23
23
|
fetcher?: GenerationFetcher<TInput, TResult>
|
|
24
|
-
/**
|
|
25
|
-
|
|
24
|
+
/** Stable scope for this generation. Also the wire and DevTools identity. */
|
|
25
|
+
threadId: string
|
|
26
26
|
/** Additional body parameters to send with connect-based adapter requests */
|
|
27
27
|
body?: Record<string, any>
|
|
28
28
|
/** Display options for TanStack AI Devtools. */
|
package/src/use-summarize.tsrx
CHANGED
|
@@ -19,8 +19,8 @@ export interface UseSummarizeOptions<TOutput = SummarizationResult> {
|
|
|
19
19
|
connection?: ConnectConnectionAdapter
|
|
20
20
|
/** Direct async function for summarization */
|
|
21
21
|
fetcher?: GenerationFetcher<SummarizeGenerateInput, SummarizationResult>
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/** Stable scope for this generation. Also the wire and DevTools identity. */
|
|
23
|
+
threadId: string
|
|
24
24
|
/** Additional body parameters to send with connect-based adapter requests */
|
|
25
25
|
body?: Record<string, any>
|
|
26
26
|
/** Display options for TanStack AI Devtools. */
|
|
@@ -73,6 +73,7 @@ export interface UseSummarizeReturn<TOutput = SummarizationResult> {
|
|
|
73
73
|
*
|
|
74
74
|
* function Summarizer() {
|
|
75
75
|
* const { generate, result, isLoading } = useSummarize({
|
|
76
|
+
* threadId: 'article-summary',
|
|
76
77
|
* connection: fetchServerSentEvents('/api/summarize'),
|
|
77
78
|
* })
|
|
78
79
|
*
|
|
@@ -18,8 +18,8 @@ export interface UseSummarizeOptions<TOutput = SummarizationResult> {
|
|
|
18
18
|
connection?: ConnectConnectionAdapter
|
|
19
19
|
/** Direct async function for summarization */
|
|
20
20
|
fetcher?: GenerationFetcher<SummarizeGenerateInput, SummarizationResult>
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/** Stable scope for this generation. Also the wire and DevTools identity. */
|
|
22
|
+
threadId: string
|
|
23
23
|
/** Additional body parameters to send with connect-based adapter requests */
|
|
24
24
|
body?: Record<string, any>
|
|
25
25
|
/** Display options for TanStack AI Devtools. */
|
|
@@ -70,6 +70,7 @@ export interface UseSummarizeReturn<TOutput = SummarizationResult> {
|
|
|
70
70
|
*
|
|
71
71
|
* function Summarizer() {
|
|
72
72
|
* const { generate, result, isLoading } = useSummarize({
|
|
73
|
+
* threadId: 'article-summary',
|
|
73
74
|
* connection: fetchServerSentEvents('/api/summarize'),
|
|
74
75
|
* })
|
|
75
76
|
*
|
|
@@ -19,8 +19,8 @@ export interface UseTranscriptionOptions<TOutput = TranscriptionResult> {
|
|
|
19
19
|
connection?: ConnectConnectionAdapter
|
|
20
20
|
/** Direct async function for transcription */
|
|
21
21
|
fetcher?: GenerationFetcher<TranscriptionGenerateInput, TranscriptionResult>
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/** Stable scope for this generation. Also the wire and DevTools identity. */
|
|
23
|
+
threadId: string
|
|
24
24
|
/** Additional body parameters to send with connect-based adapter requests */
|
|
25
25
|
body?: Record<string, any>
|
|
26
26
|
/** Display options for TanStack AI Devtools. */
|
|
@@ -73,6 +73,7 @@ export interface UseTranscriptionReturn<TOutput = TranscriptionResult> {
|
|
|
73
73
|
*
|
|
74
74
|
* function Transcriber() {
|
|
75
75
|
* const { generate, result, isLoading } = useTranscription({
|
|
76
|
+
* threadId: 'meeting-transcript',
|
|
76
77
|
* connection: fetchServerSentEvents('/api/transcribe'),
|
|
77
78
|
* })
|
|
78
79
|
*
|
|
@@ -18,8 +18,8 @@ export interface UseTranscriptionOptions<TOutput = TranscriptionResult> {
|
|
|
18
18
|
connection?: ConnectConnectionAdapter
|
|
19
19
|
/** Direct async function for transcription */
|
|
20
20
|
fetcher?: GenerationFetcher<TranscriptionGenerateInput, TranscriptionResult>
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/** Stable scope for this generation. Also the wire and DevTools identity. */
|
|
22
|
+
threadId: string
|
|
23
23
|
/** Additional body parameters to send with connect-based adapter requests */
|
|
24
24
|
body?: Record<string, any>
|
|
25
25
|
/** Display options for TanStack AI Devtools. */
|
|
@@ -70,6 +70,7 @@ export interface UseTranscriptionReturn<TOutput = TranscriptionResult> {
|
|
|
70
70
|
*
|
|
71
71
|
* function Transcriber() {
|
|
72
72
|
* const { generate, result, isLoading } = useTranscription({
|
|
73
|
+
* threadId: 'meeting-transcript',
|
|
73
74
|
* connection: fetchServerSentEvents('/api/transcribe'),
|
|
74
75
|
* })
|
|
75
76
|
*
|
|
@@ -16,12 +16,6 @@ export type UseRegisterWebMCPToolsOptions<
|
|
|
16
16
|
onError?: (error: unknown) => void
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/** @deprecated Use `UseRegisterWebMCPToolsOptions`. Removed in 1.0.0. */
|
|
20
|
-
export type UseWebMCPToolsOptions<
|
|
21
|
-
TTools extends ReadonlyArray<AnyClientTool>,
|
|
22
|
-
TContext = InferredClientContext<TTools>,
|
|
23
|
-
> = UseRegisterWebMCPToolsOptions<TTools, TContext>
|
|
24
|
-
|
|
25
19
|
type UseRegisterWebMCPToolsArguments<
|
|
26
20
|
TTools extends ReadonlyArray<AnyClientTool>,
|
|
27
21
|
TContext,
|
|
@@ -68,9 +62,6 @@ export function useRegisterWebMCPTools<
|
|
|
68
62
|
}, [tools, options])
|
|
69
63
|
}
|
|
70
64
|
|
|
71
|
-
/** @deprecated Use `useRegisterWebMCPTools`. Removed in 1.0.0. */
|
|
72
|
-
export const useWebMCPTools = useRegisterWebMCPTools
|
|
73
|
-
|
|
74
65
|
/** Options for {@link usePageWebMCPTools}. */
|
|
75
66
|
export type UsePageWebMCPToolsOptions = Omit<
|
|
76
67
|
SubscribeWebMCPToolsOptions,
|
|
@@ -91,7 +82,7 @@ export type UsePageWebMCPToolsOptions = Omit<
|
|
|
91
82
|
* const pageTools = usePageWebMCPTools({
|
|
92
83
|
* filter: (tool) => tool.origin === location.origin,
|
|
93
84
|
* })
|
|
94
|
-
* const chat = useChat({ connection, tools: pageTools })
|
|
85
|
+
* const chat = useChat({ threadId: 'support-1', connection, tools: pageTools })
|
|
95
86
|
* ```
|
|
96
87
|
*/
|
|
97
88
|
export function usePageWebMCPTools(
|
|
@@ -14,11 +14,6 @@ export type UseRegisterWebMCPToolsOptions<
|
|
|
14
14
|
/** Receives an asynchronous registration failure. */
|
|
15
15
|
onError?: (error: unknown) => void
|
|
16
16
|
}
|
|
17
|
-
/** @deprecated Use `UseRegisterWebMCPToolsOptions`. Removed in 1.0.0. */
|
|
18
|
-
export type UseWebMCPToolsOptions<
|
|
19
|
-
TTools extends ReadonlyArray<AnyClientTool>,
|
|
20
|
-
TContext = InferredClientContext<TTools>,
|
|
21
|
-
> = UseRegisterWebMCPToolsOptions<TTools, TContext>
|
|
22
17
|
type UseRegisterWebMCPToolsArguments<
|
|
23
18
|
TTools extends ReadonlyArray<AnyClientTool>,
|
|
24
19
|
TContext,
|
|
@@ -49,8 +44,6 @@ export declare function useRegisterWebMCPTools<
|
|
|
49
44
|
tools: TTools,
|
|
50
45
|
...[options]: UseRegisterWebMCPToolsArguments<TTools, TContext>
|
|
51
46
|
): void
|
|
52
|
-
/** @deprecated Use `useRegisterWebMCPTools`. Removed in 1.0.0. */
|
|
53
|
-
export declare const useWebMCPTools: typeof useRegisterWebMCPTools
|
|
54
47
|
/** Options for {@link usePageWebMCPTools}. */
|
|
55
48
|
export type UsePageWebMCPToolsOptions = Omit<
|
|
56
49
|
SubscribeWebMCPToolsOptions,
|
|
@@ -70,7 +63,7 @@ export type UsePageWebMCPToolsOptions = Omit<
|
|
|
70
63
|
* const pageTools = usePageWebMCPTools({
|
|
71
64
|
* filter: (tool) => tool.origin === location.origin,
|
|
72
65
|
* })
|
|
73
|
-
* const chat = useChat({ connection, tools: pageTools })
|
|
66
|
+
* const chat = useChat({ threadId: 'support-1', connection, tools: pageTools })
|
|
74
67
|
* ```
|
|
75
68
|
*/
|
|
76
69
|
export declare function usePageWebMCPTools(
|