ai 4.1.59 → 4.1.61
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 +17 -0
- package/dist/index.d.mts +46 -38
- package/dist/index.d.ts +46 -38
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/rsc/dist/index.d.ts +4 -0
- package/rsc/dist/rsc-server.d.mts +4 -0
- package/rsc/dist/rsc-server.mjs +2 -0
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 4.1.61
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 2e1101a: feat (provider/openai): pdf input support
|
8
|
+
- Updated dependencies [2e1101a]
|
9
|
+
- @ai-sdk/provider@1.0.11
|
10
|
+
- @ai-sdk/provider-utils@2.1.13
|
11
|
+
- @ai-sdk/ui-utils@1.1.19
|
12
|
+
- @ai-sdk/react@1.1.23
|
13
|
+
|
14
|
+
## 4.1.60
|
15
|
+
|
16
|
+
### Patch Changes
|
17
|
+
|
18
|
+
- 0b8797f: feat (ai/core): expose response body for each generateText step
|
19
|
+
|
3
20
|
## 4.1.59
|
4
21
|
|
5
22
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -674,6 +674,10 @@ interface FilePart {
|
|
674
674
|
*/
|
675
675
|
data: DataContent | URL;
|
676
676
|
/**
|
677
|
+
Optional filename of the file.
|
678
|
+
*/
|
679
|
+
filename?: string;
|
680
|
+
/**
|
677
681
|
Mime type of the file.
|
678
682
|
*/
|
679
683
|
mimeType: string;
|
@@ -1570,16 +1574,6 @@ Callback that is called when the LLM response and the final object validation ar
|
|
1570
1574
|
};
|
1571
1575
|
}): StreamObjectResult<JSONValue, JSONValue, never>;
|
1572
1576
|
|
1573
|
-
/**
|
1574
|
-
* Appends a client message to the messages array.
|
1575
|
-
* If the last message in the array has the same id as the new message, it will be replaced.
|
1576
|
-
* Otherwise, the new message will be appended.
|
1577
|
-
*/
|
1578
|
-
declare function appendClientMessage({ messages, message, }: {
|
1579
|
-
messages: Message[];
|
1580
|
-
message: Message;
|
1581
|
-
}): Message[];
|
1582
|
-
|
1583
1577
|
type ReasoningDetail = {
|
1584
1578
|
type: 'text';
|
1585
1579
|
text: string;
|
@@ -2612,6 +2606,10 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
2612
2606
|
They contain a generated id.
|
2613
2607
|
*/
|
2614
2608
|
readonly messages: Array<ResponseMessage>;
|
2609
|
+
/**
|
2610
|
+
Response body (available only for providers that use HTTP requests).
|
2611
|
+
*/
|
2612
|
+
body?: unknown;
|
2615
2613
|
};
|
2616
2614
|
/**
|
2617
2615
|
Additional provider-specific metadata. They are passed through
|
@@ -2635,32 +2633,6 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
2635
2633
|
readonly isContinued: boolean;
|
2636
2634
|
};
|
2637
2635
|
|
2638
|
-
/**
|
2639
|
-
* Appends the ResponseMessage[] from the response to a Message[] (for useChat).
|
2640
|
-
* The messages are converted to Messages before being appended.
|
2641
|
-
* Timestamps are generated for the new messages.
|
2642
|
-
*
|
2643
|
-
* @returns A new Message[] with the response messages appended.
|
2644
|
-
*/
|
2645
|
-
declare function appendResponseMessages({ messages, responseMessages, _internal: { currentDate }, }: {
|
2646
|
-
messages: Message[];
|
2647
|
-
responseMessages: ResponseMessage[];
|
2648
|
-
/**
|
2649
|
-
Internal. For test use only. May change without notice.
|
2650
|
-
*/
|
2651
|
-
_internal?: {
|
2652
|
-
currentDate?: () => Date;
|
2653
|
-
};
|
2654
|
-
}): Message[];
|
2655
|
-
|
2656
|
-
/**
|
2657
|
-
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
2658
|
-
with the AI core functions (e.g. `streamText`).
|
2659
|
-
*/
|
2660
|
-
declare function convertToCoreMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<Message, 'id'>>, options?: {
|
2661
|
-
tools?: TOOLS;
|
2662
|
-
}): CoreMessage[];
|
2663
|
-
|
2664
2636
|
/**
|
2665
2637
|
The result of a `generateText` call.
|
2666
2638
|
It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
|
@@ -2730,7 +2702,7 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
|
|
2730
2702
|
If there are tools that do not have execute functions, they are not included in the tool results and
|
2731
2703
|
need to be added separately.
|
2732
2704
|
*/
|
2733
|
-
messages: Array<
|
2705
|
+
messages: Array<ResponseMessage>;
|
2734
2706
|
/**
|
2735
2707
|
Response body (available only for providers that use HTTP requests).
|
2736
2708
|
*/
|
@@ -2819,6 +2791,42 @@ declare class NoSuchToolError extends AISDKError {
|
|
2819
2791
|
static isInstance(error: unknown): error is NoSuchToolError;
|
2820
2792
|
}
|
2821
2793
|
|
2794
|
+
/**
|
2795
|
+
* Appends a client message to the messages array.
|
2796
|
+
* If the last message in the array has the same id as the new message, it will be replaced.
|
2797
|
+
* Otherwise, the new message will be appended.
|
2798
|
+
*/
|
2799
|
+
declare function appendClientMessage({ messages, message, }: {
|
2800
|
+
messages: Message[];
|
2801
|
+
message: Message;
|
2802
|
+
}): Message[];
|
2803
|
+
|
2804
|
+
/**
|
2805
|
+
* Appends the ResponseMessage[] from the response to a Message[] (for useChat).
|
2806
|
+
* The messages are converted to Messages before being appended.
|
2807
|
+
* Timestamps are generated for the new messages.
|
2808
|
+
*
|
2809
|
+
* @returns A new Message[] with the response messages appended.
|
2810
|
+
*/
|
2811
|
+
declare function appendResponseMessages({ messages, responseMessages, _internal: { currentDate }, }: {
|
2812
|
+
messages: Message[];
|
2813
|
+
responseMessages: ResponseMessage[];
|
2814
|
+
/**
|
2815
|
+
Internal. For test use only. May change without notice.
|
2816
|
+
*/
|
2817
|
+
_internal?: {
|
2818
|
+
currentDate?: () => Date;
|
2819
|
+
};
|
2820
|
+
}): Message[];
|
2821
|
+
|
2822
|
+
/**
|
2823
|
+
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
2824
|
+
with the AI core functions (e.g. `streamText`).
|
2825
|
+
*/
|
2826
|
+
declare function convertToCoreMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<Message, 'id'>>, options?: {
|
2827
|
+
tools?: TOOLS;
|
2828
|
+
}): CoreMessage[];
|
2829
|
+
|
2822
2830
|
/**
|
2823
2831
|
* A function that attempts to repair a tool call that failed to parse.
|
2824
2832
|
*
|
@@ -3110,7 +3118,7 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
|
3110
3118
|
If there are tools that do not have execute functions, they are not included in the tool results and
|
3111
3119
|
need to be added separately.
|
3112
3120
|
*/
|
3113
|
-
messages: Array<
|
3121
|
+
messages: Array<ResponseMessage>;
|
3114
3122
|
}>;
|
3115
3123
|
/**
|
3116
3124
|
A text stream that returns only the generated text deltas. You can use it
|
package/dist/index.d.ts
CHANGED
@@ -674,6 +674,10 @@ interface FilePart {
|
|
674
674
|
*/
|
675
675
|
data: DataContent | URL;
|
676
676
|
/**
|
677
|
+
Optional filename of the file.
|
678
|
+
*/
|
679
|
+
filename?: string;
|
680
|
+
/**
|
677
681
|
Mime type of the file.
|
678
682
|
*/
|
679
683
|
mimeType: string;
|
@@ -1570,16 +1574,6 @@ Callback that is called when the LLM response and the final object validation ar
|
|
1570
1574
|
};
|
1571
1575
|
}): StreamObjectResult<JSONValue, JSONValue, never>;
|
1572
1576
|
|
1573
|
-
/**
|
1574
|
-
* Appends a client message to the messages array.
|
1575
|
-
* If the last message in the array has the same id as the new message, it will be replaced.
|
1576
|
-
* Otherwise, the new message will be appended.
|
1577
|
-
*/
|
1578
|
-
declare function appendClientMessage({ messages, message, }: {
|
1579
|
-
messages: Message[];
|
1580
|
-
message: Message;
|
1581
|
-
}): Message[];
|
1582
|
-
|
1583
1577
|
type ReasoningDetail = {
|
1584
1578
|
type: 'text';
|
1585
1579
|
text: string;
|
@@ -2612,6 +2606,10 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
2612
2606
|
They contain a generated id.
|
2613
2607
|
*/
|
2614
2608
|
readonly messages: Array<ResponseMessage>;
|
2609
|
+
/**
|
2610
|
+
Response body (available only for providers that use HTTP requests).
|
2611
|
+
*/
|
2612
|
+
body?: unknown;
|
2615
2613
|
};
|
2616
2614
|
/**
|
2617
2615
|
Additional provider-specific metadata. They are passed through
|
@@ -2635,32 +2633,6 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
2635
2633
|
readonly isContinued: boolean;
|
2636
2634
|
};
|
2637
2635
|
|
2638
|
-
/**
|
2639
|
-
* Appends the ResponseMessage[] from the response to a Message[] (for useChat).
|
2640
|
-
* The messages are converted to Messages before being appended.
|
2641
|
-
* Timestamps are generated for the new messages.
|
2642
|
-
*
|
2643
|
-
* @returns A new Message[] with the response messages appended.
|
2644
|
-
*/
|
2645
|
-
declare function appendResponseMessages({ messages, responseMessages, _internal: { currentDate }, }: {
|
2646
|
-
messages: Message[];
|
2647
|
-
responseMessages: ResponseMessage[];
|
2648
|
-
/**
|
2649
|
-
Internal. For test use only. May change without notice.
|
2650
|
-
*/
|
2651
|
-
_internal?: {
|
2652
|
-
currentDate?: () => Date;
|
2653
|
-
};
|
2654
|
-
}): Message[];
|
2655
|
-
|
2656
|
-
/**
|
2657
|
-
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
2658
|
-
with the AI core functions (e.g. `streamText`).
|
2659
|
-
*/
|
2660
|
-
declare function convertToCoreMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<Message, 'id'>>, options?: {
|
2661
|
-
tools?: TOOLS;
|
2662
|
-
}): CoreMessage[];
|
2663
|
-
|
2664
2636
|
/**
|
2665
2637
|
The result of a `generateText` call.
|
2666
2638
|
It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
|
@@ -2730,7 +2702,7 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
|
|
2730
2702
|
If there are tools that do not have execute functions, they are not included in the tool results and
|
2731
2703
|
need to be added separately.
|
2732
2704
|
*/
|
2733
|
-
messages: Array<
|
2705
|
+
messages: Array<ResponseMessage>;
|
2734
2706
|
/**
|
2735
2707
|
Response body (available only for providers that use HTTP requests).
|
2736
2708
|
*/
|
@@ -2819,6 +2791,42 @@ declare class NoSuchToolError extends AISDKError {
|
|
2819
2791
|
static isInstance(error: unknown): error is NoSuchToolError;
|
2820
2792
|
}
|
2821
2793
|
|
2794
|
+
/**
|
2795
|
+
* Appends a client message to the messages array.
|
2796
|
+
* If the last message in the array has the same id as the new message, it will be replaced.
|
2797
|
+
* Otherwise, the new message will be appended.
|
2798
|
+
*/
|
2799
|
+
declare function appendClientMessage({ messages, message, }: {
|
2800
|
+
messages: Message[];
|
2801
|
+
message: Message;
|
2802
|
+
}): Message[];
|
2803
|
+
|
2804
|
+
/**
|
2805
|
+
* Appends the ResponseMessage[] from the response to a Message[] (for useChat).
|
2806
|
+
* The messages are converted to Messages before being appended.
|
2807
|
+
* Timestamps are generated for the new messages.
|
2808
|
+
*
|
2809
|
+
* @returns A new Message[] with the response messages appended.
|
2810
|
+
*/
|
2811
|
+
declare function appendResponseMessages({ messages, responseMessages, _internal: { currentDate }, }: {
|
2812
|
+
messages: Message[];
|
2813
|
+
responseMessages: ResponseMessage[];
|
2814
|
+
/**
|
2815
|
+
Internal. For test use only. May change without notice.
|
2816
|
+
*/
|
2817
|
+
_internal?: {
|
2818
|
+
currentDate?: () => Date;
|
2819
|
+
};
|
2820
|
+
}): Message[];
|
2821
|
+
|
2822
|
+
/**
|
2823
|
+
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
2824
|
+
with the AI core functions (e.g. `streamText`).
|
2825
|
+
*/
|
2826
|
+
declare function convertToCoreMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<Message, 'id'>>, options?: {
|
2827
|
+
tools?: TOOLS;
|
2828
|
+
}): CoreMessage[];
|
2829
|
+
|
2822
2830
|
/**
|
2823
2831
|
* A function that attempts to repair a tool call that failed to parse.
|
2824
2832
|
*
|
@@ -3110,7 +3118,7 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
|
3110
3118
|
If there are tools that do not have execute functions, they are not included in the tool results and
|
3111
3119
|
need to be added separately.
|
3112
3120
|
*/
|
3113
|
-
messages: Array<
|
3121
|
+
messages: Array<ResponseMessage>;
|
3114
3122
|
}>;
|
3115
3123
|
/**
|
3116
3124
|
A text stream that returns only the generated text deltas. You can use it
|
package/dist/index.js
CHANGED
@@ -1399,6 +1399,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
1399
1399
|
return {
|
1400
1400
|
type: "file",
|
1401
1401
|
data: normalizedData instanceof Uint8Array ? convertDataContentToBase64String(normalizedData) : normalizedData,
|
1402
|
+
filename: part.filename,
|
1402
1403
|
mimeType,
|
1403
1404
|
providerMetadata: (_d = part.providerOptions) != null ? _d : part.experimental_providerMetadata
|
1404
1405
|
};
|
@@ -1917,6 +1918,7 @@ var imagePartSchema = import_zod5.z.object({
|
|
1917
1918
|
var filePartSchema = import_zod5.z.object({
|
1918
1919
|
type: import_zod5.z.literal("file"),
|
1919
1920
|
data: import_zod5.z.union([dataContentSchema, import_zod5.z.instanceof(URL)]),
|
1921
|
+
filename: import_zod5.z.string().optional(),
|
1920
1922
|
mimeType: import_zod5.z.string(),
|
1921
1923
|
providerOptions: providerMetadataSchema.optional(),
|
1922
1924
|
experimental_providerMetadata: providerMetadataSchema.optional()
|
@@ -3999,7 +4001,7 @@ async function generateText({
|
|
3999
4001
|
}),
|
4000
4002
|
tracer,
|
4001
4003
|
fn: async (span) => {
|
4002
|
-
var _a18, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
4004
|
+
var _a18, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
4003
4005
|
const mode = {
|
4004
4006
|
type: "regular",
|
4005
4007
|
...prepareToolsAndToolChoice({ tools, toolChoice, activeTools })
|
@@ -4205,6 +4207,7 @@ async function generateText({
|
|
4205
4207
|
response: {
|
4206
4208
|
...currentModelResponse.response,
|
4207
4209
|
headers: (_g = currentModelResponse.rawResponse) == null ? void 0 : _g.headers,
|
4210
|
+
body: (_h = currentModelResponse.rawResponse) == null ? void 0 : _h.body,
|
4208
4211
|
// deep clone msgs to avoid mutating past messages in multi-step:
|
4209
4212
|
messages: structuredClone(responseMessages)
|
4210
4213
|
},
|
@@ -4251,11 +4254,11 @@ async function generateText({
|
|
4251
4254
|
finishReason: currentModelResponse.finishReason,
|
4252
4255
|
usage,
|
4253
4256
|
warnings: currentModelResponse.warnings,
|
4254
|
-
request: (
|
4257
|
+
request: (_i = currentModelResponse.request) != null ? _i : {},
|
4255
4258
|
response: {
|
4256
4259
|
...currentModelResponse.response,
|
4257
|
-
headers: (
|
4258
|
-
body: (
|
4260
|
+
headers: (_j = currentModelResponse.rawResponse) == null ? void 0 : _j.headers,
|
4261
|
+
body: (_k = currentModelResponse.rawResponse) == null ? void 0 : _k.body,
|
4259
4262
|
messages: responseMessages
|
4260
4263
|
},
|
4261
4264
|
logprobs: currentModelResponse.logprobs,
|