ai 4.1.4 → 4.1.6
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 +18 -0
- package/dist/index.d.mts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +25 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 4.1.6
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- Updated dependencies [39e5c1f]
|
8
|
+
- @ai-sdk/provider-utils@2.1.3
|
9
|
+
- @ai-sdk/react@1.1.4
|
10
|
+
- @ai-sdk/ui-utils@1.1.4
|
11
|
+
|
12
|
+
## 4.1.5
|
13
|
+
|
14
|
+
### Patch Changes
|
15
|
+
|
16
|
+
- 9ce598c: feat (ai/ui): add reasoning support to useChat
|
17
|
+
- Updated dependencies [9ce598c]
|
18
|
+
- @ai-sdk/ui-utils@1.1.3
|
19
|
+
- @ai-sdk/react@1.1.3
|
20
|
+
|
3
21
|
## 4.1.4
|
4
22
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -2011,20 +2011,26 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>, PARTIAL_OUTPU
|
|
2011
2011
|
@param data an optional StreamData object that will be merged into the stream.
|
2012
2012
|
@param getErrorMessage an optional function that converts an error to an error message.
|
2013
2013
|
@param sendUsage whether to send the usage information to the client. Defaults to true.
|
2014
|
-
|
2014
|
+
@param sendReasoning whether to send the reasoning information to the client. Defaults to false.
|
2015
2015
|
@return A data stream.
|
2016
2016
|
*/
|
2017
2017
|
toDataStream(options?: {
|
2018
2018
|
data?: StreamData;
|
2019
2019
|
getErrorMessage?: (error: unknown) => string;
|
2020
2020
|
sendUsage?: boolean;
|
2021
|
+
sendReasoning?: boolean;
|
2021
2022
|
}): ReadableStream<Uint8Array>;
|
2022
2023
|
/**
|
2023
2024
|
* Merges the result as a data stream into another data stream.
|
2024
2025
|
*
|
2025
2026
|
* @param dataStream A data stream writer.
|
2027
|
+
* @param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
2028
|
+
* @param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
2026
2029
|
*/
|
2027
|
-
mergeIntoDataStream(dataStream: DataStreamWriter
|
2030
|
+
mergeIntoDataStream(dataStream: DataStreamWriter, options?: {
|
2031
|
+
sendUsage?: boolean;
|
2032
|
+
sendReasoning?: boolean;
|
2033
|
+
}): void;
|
2028
2034
|
/**
|
2029
2035
|
Writes data stream output to a Node.js response-like object.
|
2030
2036
|
|
@@ -2035,11 +2041,13 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>, PARTIAL_OUTPU
|
|
2035
2041
|
@param options.data The stream data.
|
2036
2042
|
@param options.getErrorMessage An optional function that converts an error to an error message.
|
2037
2043
|
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
2044
|
+
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
2038
2045
|
*/
|
2039
2046
|
pipeDataStreamToResponse(response: ServerResponse, options?: ResponseInit & {
|
2040
2047
|
data?: StreamData;
|
2041
2048
|
getErrorMessage?: (error: unknown) => string;
|
2042
2049
|
sendUsage?: boolean;
|
2050
|
+
sendReasoning?: boolean;
|
2043
2051
|
}): void;
|
2044
2052
|
/**
|
2045
2053
|
Writes text delta output to a Node.js response-like object.
|
@@ -2060,6 +2068,7 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>, PARTIAL_OUTPU
|
|
2060
2068
|
@param options.data The stream data.
|
2061
2069
|
@param options.getErrorMessage An optional function that converts an error to an error message.
|
2062
2070
|
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
2071
|
+
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
2063
2072
|
|
2064
2073
|
@return A response object.
|
2065
2074
|
*/
|
@@ -2067,6 +2076,7 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>, PARTIAL_OUTPU
|
|
2067
2076
|
data?: StreamData;
|
2068
2077
|
getErrorMessage?: (error: unknown) => string;
|
2069
2078
|
sendUsage?: boolean;
|
2079
|
+
sendReasoning?: boolean;
|
2070
2080
|
}): Response;
|
2071
2081
|
/**
|
2072
2082
|
Creates a simple text stream response.
|
package/dist/index.d.ts
CHANGED
@@ -2011,20 +2011,26 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>, PARTIAL_OUTPU
|
|
2011
2011
|
@param data an optional StreamData object that will be merged into the stream.
|
2012
2012
|
@param getErrorMessage an optional function that converts an error to an error message.
|
2013
2013
|
@param sendUsage whether to send the usage information to the client. Defaults to true.
|
2014
|
-
|
2014
|
+
@param sendReasoning whether to send the reasoning information to the client. Defaults to false.
|
2015
2015
|
@return A data stream.
|
2016
2016
|
*/
|
2017
2017
|
toDataStream(options?: {
|
2018
2018
|
data?: StreamData;
|
2019
2019
|
getErrorMessage?: (error: unknown) => string;
|
2020
2020
|
sendUsage?: boolean;
|
2021
|
+
sendReasoning?: boolean;
|
2021
2022
|
}): ReadableStream<Uint8Array>;
|
2022
2023
|
/**
|
2023
2024
|
* Merges the result as a data stream into another data stream.
|
2024
2025
|
*
|
2025
2026
|
* @param dataStream A data stream writer.
|
2027
|
+
* @param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
2028
|
+
* @param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
2026
2029
|
*/
|
2027
|
-
mergeIntoDataStream(dataStream: DataStreamWriter
|
2030
|
+
mergeIntoDataStream(dataStream: DataStreamWriter, options?: {
|
2031
|
+
sendUsage?: boolean;
|
2032
|
+
sendReasoning?: boolean;
|
2033
|
+
}): void;
|
2028
2034
|
/**
|
2029
2035
|
Writes data stream output to a Node.js response-like object.
|
2030
2036
|
|
@@ -2035,11 +2041,13 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>, PARTIAL_OUTPU
|
|
2035
2041
|
@param options.data The stream data.
|
2036
2042
|
@param options.getErrorMessage An optional function that converts an error to an error message.
|
2037
2043
|
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
2044
|
+
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
2038
2045
|
*/
|
2039
2046
|
pipeDataStreamToResponse(response: ServerResponse, options?: ResponseInit & {
|
2040
2047
|
data?: StreamData;
|
2041
2048
|
getErrorMessage?: (error: unknown) => string;
|
2042
2049
|
sendUsage?: boolean;
|
2050
|
+
sendReasoning?: boolean;
|
2043
2051
|
}): void;
|
2044
2052
|
/**
|
2045
2053
|
Writes text delta output to a Node.js response-like object.
|
@@ -2060,6 +2068,7 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>, PARTIAL_OUTPU
|
|
2060
2068
|
@param options.data The stream data.
|
2061
2069
|
@param options.getErrorMessage An optional function that converts an error to an error message.
|
2062
2070
|
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
2071
|
+
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
2063
2072
|
|
2064
2073
|
@return A response object.
|
2065
2074
|
*/
|
@@ -2067,6 +2076,7 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>, PARTIAL_OUTPU
|
|
2067
2076
|
data?: StreamData;
|
2068
2077
|
getErrorMessage?: (error: unknown) => string;
|
2069
2078
|
sendUsage?: boolean;
|
2079
|
+
sendReasoning?: boolean;
|
2070
2080
|
}): Response;
|
2071
2081
|
/**
|
2072
2082
|
Creates a simple text stream response.
|
package/dist/index.js
CHANGED
@@ -5401,8 +5401,9 @@ var DefaultStreamTextResult = class {
|
|
5401
5401
|
toDataStreamInternal({
|
5402
5402
|
getErrorMessage: getErrorMessage5 = () => "An error occurred.",
|
5403
5403
|
// mask error messages for safety by default
|
5404
|
-
sendUsage = true
|
5405
|
-
|
5404
|
+
sendUsage = true,
|
5405
|
+
sendReasoning = false
|
5406
|
+
}) {
|
5406
5407
|
let aggregatedResponse = "";
|
5407
5408
|
const callbackTransformer = new TransformStream({
|
5408
5409
|
async transform(chunk, controller) {
|
@@ -5421,9 +5422,11 @@ var DefaultStreamTextResult = class {
|
|
5421
5422
|
break;
|
5422
5423
|
}
|
5423
5424
|
case "reasoning": {
|
5424
|
-
|
5425
|
-
|
5426
|
-
|
5425
|
+
if (sendReasoning) {
|
5426
|
+
controller.enqueue(
|
5427
|
+
(0, import_ui_utils8.formatDataStreamPart)("reasoning", chunk.textDelta)
|
5428
|
+
);
|
5429
|
+
}
|
5427
5430
|
break;
|
5428
5431
|
}
|
5429
5432
|
case "tool-call-streaming-start": {
|
@@ -5517,7 +5520,8 @@ var DefaultStreamTextResult = class {
|
|
5517
5520
|
headers,
|
5518
5521
|
data,
|
5519
5522
|
getErrorMessage: getErrorMessage5,
|
5520
|
-
sendUsage
|
5523
|
+
sendUsage,
|
5524
|
+
sendReasoning
|
5521
5525
|
} = {}) {
|
5522
5526
|
writeToServerResponse({
|
5523
5527
|
response,
|
@@ -5527,7 +5531,12 @@ var DefaultStreamTextResult = class {
|
|
5527
5531
|
contentType: "text/plain; charset=utf-8",
|
5528
5532
|
dataStreamVersion: "v1"
|
5529
5533
|
}),
|
5530
|
-
stream: this.toDataStream({
|
5534
|
+
stream: this.toDataStream({
|
5535
|
+
data,
|
5536
|
+
getErrorMessage: getErrorMessage5,
|
5537
|
+
sendUsage,
|
5538
|
+
sendReasoning
|
5539
|
+
})
|
5531
5540
|
});
|
5532
5541
|
}
|
5533
5542
|
pipeTextStreamToResponse(response, init) {
|
@@ -5545,14 +5554,17 @@ var DefaultStreamTextResult = class {
|
|
5545
5554
|
toDataStream(options) {
|
5546
5555
|
const stream = this.toDataStreamInternal({
|
5547
5556
|
getErrorMessage: options == null ? void 0 : options.getErrorMessage,
|
5548
|
-
sendUsage: options == null ? void 0 : options.sendUsage
|
5557
|
+
sendUsage: options == null ? void 0 : options.sendUsage,
|
5558
|
+
sendReasoning: options == null ? void 0 : options.sendReasoning
|
5549
5559
|
}).pipeThrough(new TextEncoderStream());
|
5550
5560
|
return (options == null ? void 0 : options.data) ? mergeStreams(options == null ? void 0 : options.data.stream, stream) : stream;
|
5551
5561
|
}
|
5552
|
-
mergeIntoDataStream(writer) {
|
5562
|
+
mergeIntoDataStream(writer, options) {
|
5553
5563
|
writer.merge(
|
5554
5564
|
this.toDataStreamInternal({
|
5555
|
-
getErrorMessage: writer.onError
|
5565
|
+
getErrorMessage: writer.onError,
|
5566
|
+
sendUsage: options == null ? void 0 : options.sendUsage,
|
5567
|
+
sendReasoning: options == null ? void 0 : options.sendReasoning
|
5556
5568
|
})
|
5557
5569
|
);
|
5558
5570
|
}
|
@@ -5562,10 +5574,11 @@ var DefaultStreamTextResult = class {
|
|
5562
5574
|
statusText,
|
5563
5575
|
data,
|
5564
5576
|
getErrorMessage: getErrorMessage5,
|
5565
|
-
sendUsage
|
5577
|
+
sendUsage,
|
5578
|
+
sendReasoning
|
5566
5579
|
} = {}) {
|
5567
5580
|
return new Response(
|
5568
|
-
this.toDataStream({ data, getErrorMessage: getErrorMessage5, sendUsage }),
|
5581
|
+
this.toDataStream({ data, getErrorMessage: getErrorMessage5, sendUsage, sendReasoning }),
|
5569
5582
|
{
|
5570
5583
|
status,
|
5571
5584
|
statusText,
|