@ai-sdk/rsc 3.0.0-beta.16 → 3.0.0-beta.179
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/CHANGELOG.md +1276 -0
- package/dist/index.d.ts +2 -2
- package/dist/rsc-server.d.mts +2 -2
- package/dist/rsc-server.mjs +19 -10
- package/dist/rsc-server.mjs.map +1 -1
- package/dist/rsc-shared.mjs.map +1 -1
- package/package.json +22 -23
- package/src/stream-ui/stream-ui.tsx +36 -24
- package/src/streamable-value/create-streamable-value.ts +2 -3
- package/src/streamable-value/is-streamable-value.ts +4 -2
- package/src/streamable-value/read-streamable-value.tsx +1 -1
- package/src/streamable-value/use-streamable-value.tsx +1 -1
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
LanguageModelV4,
|
|
3
3
|
LanguageModelV4StreamResult,
|
|
4
4
|
LanguageModelV4Usage,
|
|
5
|
-
|
|
5
|
+
SharedV4Warning,
|
|
6
6
|
} from '@ai-sdk/provider';
|
|
7
7
|
import {
|
|
8
|
-
InferSchema,
|
|
9
|
-
ProviderOptions,
|
|
10
8
|
safeParseJSON,
|
|
9
|
+
type InferSchema,
|
|
10
|
+
type ProviderOptions,
|
|
11
11
|
} from '@ai-sdk/provider-utils';
|
|
12
12
|
import {
|
|
13
|
-
CallSettings,
|
|
14
|
-
CallWarning,
|
|
15
|
-
FinishReason,
|
|
16
13
|
InvalidToolInputError,
|
|
17
|
-
LanguageModelUsage,
|
|
18
14
|
NoSuchToolError,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
type CallWarning,
|
|
16
|
+
type FinishReason,
|
|
17
|
+
type LanguageModelUsage,
|
|
18
|
+
type LanguageModelCallOptions,
|
|
19
|
+
type Prompt,
|
|
20
|
+
type RequestOptions,
|
|
21
|
+
type Schema,
|
|
22
|
+
type ToolChoice,
|
|
22
23
|
} from 'ai';
|
|
23
24
|
import {
|
|
24
25
|
asLanguageModelUsage,
|
|
25
26
|
convertToLanguageModelPrompt,
|
|
26
|
-
|
|
27
|
+
prepareLanguageModelCallOptions,
|
|
27
28
|
prepareRetries,
|
|
28
|
-
|
|
29
|
+
prepareToolChoice,
|
|
30
|
+
prepareTools,
|
|
29
31
|
standardizePrompt,
|
|
30
32
|
} from 'ai/internal';
|
|
31
|
-
import { ReactNode } from 'react';
|
|
32
|
-
import * as z3 from 'zod/v3';
|
|
33
|
-
import * as z4 from 'zod/v4';
|
|
33
|
+
import type { ReactNode } from 'react';
|
|
34
|
+
import type * as z3 from 'zod/v3';
|
|
35
|
+
import type * as z4 from 'zod/v4';
|
|
34
36
|
import { createStreamableUI } from '../streamable-ui/create-streamable-ui';
|
|
35
37
|
import { createResolvablePromise } from '../util/create-resolvable-promise';
|
|
36
38
|
import { isAsyncGenerator } from '../util/is-async-generator';
|
|
@@ -99,9 +101,11 @@ export async function streamUI<
|
|
|
99
101
|
model,
|
|
100
102
|
tools,
|
|
101
103
|
toolChoice,
|
|
104
|
+
instructions,
|
|
102
105
|
system,
|
|
103
106
|
prompt,
|
|
104
107
|
messages,
|
|
108
|
+
allowSystemInMessages,
|
|
105
109
|
maxRetries,
|
|
106
110
|
abortSignal,
|
|
107
111
|
headers,
|
|
@@ -110,7 +114,8 @@ export async function streamUI<
|
|
|
110
114
|
providerOptions,
|
|
111
115
|
onFinish,
|
|
112
116
|
...settings
|
|
113
|
-
}:
|
|
117
|
+
}: LanguageModelCallOptions &
|
|
118
|
+
Omit<RequestOptions, 'timeout'> &
|
|
114
119
|
Prompt & {
|
|
115
120
|
/**
|
|
116
121
|
* The language model to use.
|
|
@@ -266,22 +271,29 @@ export async function streamUI<
|
|
|
266
271
|
const { retry } = prepareRetries({ maxRetries, abortSignal });
|
|
267
272
|
|
|
268
273
|
const validatedPrompt = await standardizePrompt({
|
|
274
|
+
instructions,
|
|
269
275
|
system,
|
|
270
276
|
prompt,
|
|
271
277
|
messages,
|
|
278
|
+
allowSystemInMessages,
|
|
272
279
|
} as Prompt);
|
|
280
|
+
const languageModelTools = await prepareTools({
|
|
281
|
+
tools: tools,
|
|
282
|
+
});
|
|
283
|
+
const languageModelToolChoice = prepareToolChoice({
|
|
284
|
+
toolChoice,
|
|
285
|
+
});
|
|
286
|
+
|
|
273
287
|
const result = await retry(async () =>
|
|
274
288
|
model.doStream({
|
|
275
|
-
...
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
toolChoice,
|
|
279
|
-
activeTools: undefined,
|
|
280
|
-
}),
|
|
289
|
+
...prepareLanguageModelCallOptions(settings),
|
|
290
|
+
tools: languageModelTools,
|
|
291
|
+
toolChoice: languageModelToolChoice,
|
|
281
292
|
prompt: await convertToLanguageModelPrompt({
|
|
282
293
|
prompt: validatedPrompt,
|
|
283
294
|
supportedUrls: await model.supportedUrls,
|
|
284
295
|
download: undefined,
|
|
296
|
+
provider: model.provider.split('.')[0],
|
|
285
297
|
}),
|
|
286
298
|
providerOptions,
|
|
287
299
|
abortSignal,
|
|
@@ -296,7 +308,7 @@ export async function streamUI<
|
|
|
296
308
|
try {
|
|
297
309
|
let content = '';
|
|
298
310
|
let hasToolCall = false;
|
|
299
|
-
let warnings:
|
|
311
|
+
let warnings: SharedV4Warning[] | undefined;
|
|
300
312
|
|
|
301
313
|
const reader = forkedStream.getReader();
|
|
302
314
|
while (true) {
|
|
@@ -2,10 +2,9 @@ import { HANGING_STREAM_WARNING_TIME_MS } from '../util/constants';
|
|
|
2
2
|
import { createResolvablePromise } from '../util/create-resolvable-promise';
|
|
3
3
|
import {
|
|
4
4
|
STREAMABLE_VALUE_TYPE,
|
|
5
|
-
StreamablePatch,
|
|
6
|
-
StreamableValue,
|
|
5
|
+
type StreamablePatch,
|
|
6
|
+
type StreamableValue,
|
|
7
7
|
} from './streamable-value';
|
|
8
|
-
|
|
9
8
|
const STREAMABLE_VALUE_INTERNAL_LOCK = Symbol('streamable.value.lock');
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
STREAMABLE_VALUE_TYPE,
|
|
3
|
+
type StreamableValue,
|
|
4
|
+
} from './streamable-value';
|
|
3
5
|
export function isStreamableValue(value: unknown): value is StreamableValue {
|
|
4
6
|
return (
|
|
5
7
|
value != null &&
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isStreamableValue } from './is-streamable-value';
|
|
2
|
-
import { StreamableValue } from './streamable-value';
|
|
2
|
+
import type { StreamableValue } from './streamable-value';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* `readStreamableValue` takes a streamable value created via the `createStreamableValue().value` API,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { startTransition, useLayoutEffect, useState } from 'react';
|
|
2
2
|
import { readStreamableValue } from './read-streamable-value';
|
|
3
|
-
import { StreamableValue } from './streamable-value';
|
|
3
|
+
import type { StreamableValue } from './streamable-value';
|
|
4
4
|
import { isStreamableValue } from './is-streamable-value';
|
|
5
5
|
|
|
6
6
|
function checkStreamableValue(value: unknown): value is StreamableValue {
|