ai 4.1.59 → 4.1.60
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 +6 -0
- package/dist/index.d.mts +42 -38
- package/dist/index.d.ts +42 -38
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
@@ -1570,16 +1570,6 @@ Callback that is called when the LLM response and the final object validation ar
|
|
1570
1570
|
};
|
1571
1571
|
}): StreamObjectResult<JSONValue, JSONValue, never>;
|
1572
1572
|
|
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
1573
|
type ReasoningDetail = {
|
1584
1574
|
type: 'text';
|
1585
1575
|
text: string;
|
@@ -2612,6 +2602,10 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
2612
2602
|
They contain a generated id.
|
2613
2603
|
*/
|
2614
2604
|
readonly messages: Array<ResponseMessage>;
|
2605
|
+
/**
|
2606
|
+
Response body (available only for providers that use HTTP requests).
|
2607
|
+
*/
|
2608
|
+
body?: unknown;
|
2615
2609
|
};
|
2616
2610
|
/**
|
2617
2611
|
Additional provider-specific metadata. They are passed through
|
@@ -2635,32 +2629,6 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
2635
2629
|
readonly isContinued: boolean;
|
2636
2630
|
};
|
2637
2631
|
|
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
2632
|
/**
|
2665
2633
|
The result of a `generateText` call.
|
2666
2634
|
It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
|
@@ -2730,7 +2698,7 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
|
|
2730
2698
|
If there are tools that do not have execute functions, they are not included in the tool results and
|
2731
2699
|
need to be added separately.
|
2732
2700
|
*/
|
2733
|
-
messages: Array<
|
2701
|
+
messages: Array<ResponseMessage>;
|
2734
2702
|
/**
|
2735
2703
|
Response body (available only for providers that use HTTP requests).
|
2736
2704
|
*/
|
@@ -2819,6 +2787,42 @@ declare class NoSuchToolError extends AISDKError {
|
|
2819
2787
|
static isInstance(error: unknown): error is NoSuchToolError;
|
2820
2788
|
}
|
2821
2789
|
|
2790
|
+
/**
|
2791
|
+
* Appends a client message to the messages array.
|
2792
|
+
* If the last message in the array has the same id as the new message, it will be replaced.
|
2793
|
+
* Otherwise, the new message will be appended.
|
2794
|
+
*/
|
2795
|
+
declare function appendClientMessage({ messages, message, }: {
|
2796
|
+
messages: Message[];
|
2797
|
+
message: Message;
|
2798
|
+
}): Message[];
|
2799
|
+
|
2800
|
+
/**
|
2801
|
+
* Appends the ResponseMessage[] from the response to a Message[] (for useChat).
|
2802
|
+
* The messages are converted to Messages before being appended.
|
2803
|
+
* Timestamps are generated for the new messages.
|
2804
|
+
*
|
2805
|
+
* @returns A new Message[] with the response messages appended.
|
2806
|
+
*/
|
2807
|
+
declare function appendResponseMessages({ messages, responseMessages, _internal: { currentDate }, }: {
|
2808
|
+
messages: Message[];
|
2809
|
+
responseMessages: ResponseMessage[];
|
2810
|
+
/**
|
2811
|
+
Internal. For test use only. May change without notice.
|
2812
|
+
*/
|
2813
|
+
_internal?: {
|
2814
|
+
currentDate?: () => Date;
|
2815
|
+
};
|
2816
|
+
}): Message[];
|
2817
|
+
|
2818
|
+
/**
|
2819
|
+
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
2820
|
+
with the AI core functions (e.g. `streamText`).
|
2821
|
+
*/
|
2822
|
+
declare function convertToCoreMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<Message, 'id'>>, options?: {
|
2823
|
+
tools?: TOOLS;
|
2824
|
+
}): CoreMessage[];
|
2825
|
+
|
2822
2826
|
/**
|
2823
2827
|
* A function that attempts to repair a tool call that failed to parse.
|
2824
2828
|
*
|
@@ -3110,7 +3114,7 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
|
3110
3114
|
If there are tools that do not have execute functions, they are not included in the tool results and
|
3111
3115
|
need to be added separately.
|
3112
3116
|
*/
|
3113
|
-
messages: Array<
|
3117
|
+
messages: Array<ResponseMessage>;
|
3114
3118
|
}>;
|
3115
3119
|
/**
|
3116
3120
|
A text stream that returns only the generated text deltas. You can use it
|
package/dist/index.d.ts
CHANGED
@@ -1570,16 +1570,6 @@ Callback that is called when the LLM response and the final object validation ar
|
|
1570
1570
|
};
|
1571
1571
|
}): StreamObjectResult<JSONValue, JSONValue, never>;
|
1572
1572
|
|
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
1573
|
type ReasoningDetail = {
|
1584
1574
|
type: 'text';
|
1585
1575
|
text: string;
|
@@ -2612,6 +2602,10 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
2612
2602
|
They contain a generated id.
|
2613
2603
|
*/
|
2614
2604
|
readonly messages: Array<ResponseMessage>;
|
2605
|
+
/**
|
2606
|
+
Response body (available only for providers that use HTTP requests).
|
2607
|
+
*/
|
2608
|
+
body?: unknown;
|
2615
2609
|
};
|
2616
2610
|
/**
|
2617
2611
|
Additional provider-specific metadata. They are passed through
|
@@ -2635,32 +2629,6 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
2635
2629
|
readonly isContinued: boolean;
|
2636
2630
|
};
|
2637
2631
|
|
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
2632
|
/**
|
2665
2633
|
The result of a `generateText` call.
|
2666
2634
|
It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
|
@@ -2730,7 +2698,7 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
|
|
2730
2698
|
If there are tools that do not have execute functions, they are not included in the tool results and
|
2731
2699
|
need to be added separately.
|
2732
2700
|
*/
|
2733
|
-
messages: Array<
|
2701
|
+
messages: Array<ResponseMessage>;
|
2734
2702
|
/**
|
2735
2703
|
Response body (available only for providers that use HTTP requests).
|
2736
2704
|
*/
|
@@ -2819,6 +2787,42 @@ declare class NoSuchToolError extends AISDKError {
|
|
2819
2787
|
static isInstance(error: unknown): error is NoSuchToolError;
|
2820
2788
|
}
|
2821
2789
|
|
2790
|
+
/**
|
2791
|
+
* Appends a client message to the messages array.
|
2792
|
+
* If the last message in the array has the same id as the new message, it will be replaced.
|
2793
|
+
* Otherwise, the new message will be appended.
|
2794
|
+
*/
|
2795
|
+
declare function appendClientMessage({ messages, message, }: {
|
2796
|
+
messages: Message[];
|
2797
|
+
message: Message;
|
2798
|
+
}): Message[];
|
2799
|
+
|
2800
|
+
/**
|
2801
|
+
* Appends the ResponseMessage[] from the response to a Message[] (for useChat).
|
2802
|
+
* The messages are converted to Messages before being appended.
|
2803
|
+
* Timestamps are generated for the new messages.
|
2804
|
+
*
|
2805
|
+
* @returns A new Message[] with the response messages appended.
|
2806
|
+
*/
|
2807
|
+
declare function appendResponseMessages({ messages, responseMessages, _internal: { currentDate }, }: {
|
2808
|
+
messages: Message[];
|
2809
|
+
responseMessages: ResponseMessage[];
|
2810
|
+
/**
|
2811
|
+
Internal. For test use only. May change without notice.
|
2812
|
+
*/
|
2813
|
+
_internal?: {
|
2814
|
+
currentDate?: () => Date;
|
2815
|
+
};
|
2816
|
+
}): Message[];
|
2817
|
+
|
2818
|
+
/**
|
2819
|
+
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
2820
|
+
with the AI core functions (e.g. `streamText`).
|
2821
|
+
*/
|
2822
|
+
declare function convertToCoreMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<Message, 'id'>>, options?: {
|
2823
|
+
tools?: TOOLS;
|
2824
|
+
}): CoreMessage[];
|
2825
|
+
|
2822
2826
|
/**
|
2823
2827
|
* A function that attempts to repair a tool call that failed to parse.
|
2824
2828
|
*
|
@@ -3110,7 +3114,7 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
|
3110
3114
|
If there are tools that do not have execute functions, they are not included in the tool results and
|
3111
3115
|
need to be added separately.
|
3112
3116
|
*/
|
3113
|
-
messages: Array<
|
3117
|
+
messages: Array<ResponseMessage>;
|
3114
3118
|
}>;
|
3115
3119
|
/**
|
3116
3120
|
A text stream that returns only the generated text deltas. You can use it
|
package/dist/index.js
CHANGED
@@ -3999,7 +3999,7 @@ async function generateText({
|
|
3999
3999
|
}),
|
4000
4000
|
tracer,
|
4001
4001
|
fn: async (span) => {
|
4002
|
-
var _a18, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
4002
|
+
var _a18, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
4003
4003
|
const mode = {
|
4004
4004
|
type: "regular",
|
4005
4005
|
...prepareToolsAndToolChoice({ tools, toolChoice, activeTools })
|
@@ -4205,6 +4205,7 @@ async function generateText({
|
|
4205
4205
|
response: {
|
4206
4206
|
...currentModelResponse.response,
|
4207
4207
|
headers: (_g = currentModelResponse.rawResponse) == null ? void 0 : _g.headers,
|
4208
|
+
body: (_h = currentModelResponse.rawResponse) == null ? void 0 : _h.body,
|
4208
4209
|
// deep clone msgs to avoid mutating past messages in multi-step:
|
4209
4210
|
messages: structuredClone(responseMessages)
|
4210
4211
|
},
|
@@ -4251,11 +4252,11 @@ async function generateText({
|
|
4251
4252
|
finishReason: currentModelResponse.finishReason,
|
4252
4253
|
usage,
|
4253
4254
|
warnings: currentModelResponse.warnings,
|
4254
|
-
request: (
|
4255
|
+
request: (_i = currentModelResponse.request) != null ? _i : {},
|
4255
4256
|
response: {
|
4256
4257
|
...currentModelResponse.response,
|
4257
|
-
headers: (
|
4258
|
-
body: (
|
4258
|
+
headers: (_j = currentModelResponse.rawResponse) == null ? void 0 : _j.headers,
|
4259
|
+
body: (_k = currentModelResponse.rawResponse) == null ? void 0 : _k.body,
|
4259
4260
|
messages: responseMessages
|
4260
4261
|
},
|
4261
4262
|
logprobs: currentModelResponse.logprobs,
|