ai 7.0.0-beta.27 → 7.0.0-beta.29
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 +12 -0
- package/README.md +6 -16
- package/dist/index.d.mts +24 -21
- package/dist/index.d.ts +24 -21
- package/dist/index.js +177 -216
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +177 -216
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +10 -3
- package/src/agent/tool-loop-agent-settings.ts +1 -1
- package/src/embed/embed-events.ts +10 -5
- package/src/embed/embed-many.ts +6 -4
- package/src/embed/embed.ts +4 -3
- package/src/generate-text/{callback-events.ts → core-events.ts} +20 -18
- package/src/generate-text/create-execute-tools-transformation.ts +168 -0
- package/src/generate-text/execute-tool-call.ts +6 -3
- package/src/generate-text/generate-text.ts +19 -17
- package/src/generate-text/index.ts +1 -1
- package/src/generate-text/step-result.ts +5 -3
- package/src/generate-text/stream-text.ts +48 -47
- package/src/telemetry/open-telemetry-integration.ts +8 -8
- package/src/telemetry/telemetry-integration.ts +1 -1
- package/src/generate-text/execute-tools-transformation.ts +0 -236
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.0-beta.29
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 877bf12: fix(ai): flatten model attributes for telemetry
|
|
8
|
+
|
|
9
|
+
## 7.0.0-beta.28
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- b9cf502: refactoring(ai): delay tool execution in stream text until model call is finished
|
|
14
|
+
|
|
3
15
|
## 7.0.0-beta.27
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ By default, the AI SDK uses the [Vercel AI Gateway](https://vercel.com/docs/ai-g
|
|
|
30
30
|
|
|
31
31
|
```ts
|
|
32
32
|
const result = await generateText({
|
|
33
|
-
model: 'anthropic/claude-opus-4.
|
|
33
|
+
model: 'anthropic/claude-opus-4.6', // or 'openai/gpt-5.4', 'google/gemini-3-flash', etc.
|
|
34
34
|
prompt: 'Hello!',
|
|
35
35
|
});
|
|
36
36
|
```
|
|
@@ -45,7 +45,7 @@ npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google
|
|
|
45
45
|
import { anthropic } from '@ai-sdk/anthropic';
|
|
46
46
|
|
|
47
47
|
const result = await generateText({
|
|
48
|
-
model: anthropic('claude-opus-4-
|
|
48
|
+
model: anthropic('claude-opus-4-6'), // or openai('gpt-5.4'), google('gemini-3-flash'), etc.
|
|
49
49
|
prompt: 'Hello!',
|
|
50
50
|
});
|
|
51
51
|
```
|
|
@@ -58,17 +58,7 @@ const result = await generateText({
|
|
|
58
58
|
import { generateText } from 'ai';
|
|
59
59
|
|
|
60
60
|
const { text } = await generateText({
|
|
61
|
-
model: 'openai/gpt-5', // use Vercel AI Gateway
|
|
62
|
-
prompt: 'What is an agent?',
|
|
63
|
-
});
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
import { generateText } from 'ai';
|
|
68
|
-
import { openai } from '@ai-sdk/openai';
|
|
69
|
-
|
|
70
|
-
const { text } = await generateText({
|
|
71
|
-
model: openai('gpt-5'), // use OpenAI Responses API
|
|
61
|
+
model: 'openai/gpt-5.4', // use Vercel AI Gateway
|
|
72
62
|
prompt: 'What is an agent?',
|
|
73
63
|
});
|
|
74
64
|
```
|
|
@@ -80,7 +70,7 @@ import { generateText, Output } from 'ai';
|
|
|
80
70
|
import { z } from 'zod';
|
|
81
71
|
|
|
82
72
|
const { output } = await generateText({
|
|
83
|
-
model: 'openai/gpt-5',
|
|
73
|
+
model: 'openai/gpt-5.4',
|
|
84
74
|
output: Output.object({
|
|
85
75
|
schema: z.object({
|
|
86
76
|
recipe: z.object({
|
|
@@ -102,7 +92,7 @@ const { output } = await generateText({
|
|
|
102
92
|
import { ToolLoopAgent } from 'ai';
|
|
103
93
|
|
|
104
94
|
const sandboxAgent = new ToolLoopAgent({
|
|
105
|
-
model: 'openai/gpt-5',
|
|
95
|
+
model: 'openai/gpt-5.4',
|
|
106
96
|
system: 'You are an agent with access to a shell environment.',
|
|
107
97
|
tools: {
|
|
108
98
|
shell: openai.tools.localShell({
|
|
@@ -134,7 +124,7 @@ import { openai } from '@ai-sdk/openai';
|
|
|
134
124
|
import { ToolLoopAgent, InferAgentUIMessage } from 'ai';
|
|
135
125
|
|
|
136
126
|
export const imageGenerationAgent = new ToolLoopAgent({
|
|
137
|
-
model: openai
|
|
127
|
+
model: 'openai/gpt-5.4',
|
|
138
128
|
tools: {
|
|
139
129
|
generateImage: openai.tools.imageGeneration({
|
|
140
130
|
partialImages: 3,
|
package/dist/index.d.mts
CHANGED
|
@@ -2541,15 +2541,6 @@ type TextStreamRawPart = {
|
|
|
2541
2541
|
};
|
|
2542
2542
|
type TextStreamPart<TOOLS extends ToolSet> = TextStreamTextStartPart | TextStreamTextEndPart | TextStreamTextDeltaPart | TextStreamReasoningStartPart | TextStreamReasoningEndPart | TextStreamReasoningDeltaPart | TextStreamCustomPart | TextStreamToolInputStartPart | TextStreamToolInputEndPart | TextStreamToolInputDeltaPart | TextStreamSourcePart | TextStreamFilePart | TextStreamReasoningFilePart | TextStreamToolCallPart<TOOLS> | TextStreamToolResultPart<TOOLS> | TextStreamToolErrorPart<TOOLS> | TextStreamToolOutputDeniedPart<TOOLS> | TextStreamToolApprovalRequestPart<TOOLS> | TextStreamStartStepPart | TextStreamFinishStepPart | TextStreamStartPart | TextStreamFinishPart | TextStreamAbortPart | TextStreamErrorPart | TextStreamRawPart;
|
|
2543
2543
|
|
|
2544
|
-
/**
|
|
2545
|
-
* Common model information used across callback events.
|
|
2546
|
-
*/
|
|
2547
|
-
interface ModelEventInfo {
|
|
2548
|
-
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2549
|
-
readonly provider: string;
|
|
2550
|
-
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
2551
|
-
readonly modelId: string;
|
|
2552
|
-
}
|
|
2553
2544
|
/**
|
|
2554
2545
|
* Event passed to the `onStart` callback.
|
|
2555
2546
|
*
|
|
@@ -2563,8 +2554,10 @@ interface OnStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output =
|
|
|
2563
2554
|
readonly callId: string;
|
|
2564
2555
|
/** Identifies the operation type (e.g. 'ai.generateText' or 'ai.streamText'). */
|
|
2565
2556
|
readonly operationId: string;
|
|
2566
|
-
/** The
|
|
2567
|
-
readonly
|
|
2557
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2558
|
+
readonly provider: string;
|
|
2559
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
2560
|
+
readonly modelId: string;
|
|
2568
2561
|
/** The system message(s) provided to the model. */
|
|
2569
2562
|
readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
|
|
2570
2563
|
/** The prompt string or array of messages if using the prompt option. */
|
|
@@ -2647,8 +2640,10 @@ interface OnStepStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Outpu
|
|
|
2647
2640
|
readonly callId: string;
|
|
2648
2641
|
/** Zero-based index of the current step. */
|
|
2649
2642
|
readonly stepNumber: number;
|
|
2650
|
-
/** The
|
|
2651
|
-
readonly
|
|
2643
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2644
|
+
readonly provider: string;
|
|
2645
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
2646
|
+
readonly modelId: string;
|
|
2652
2647
|
/**
|
|
2653
2648
|
* The system message for this step.
|
|
2654
2649
|
*/
|
|
@@ -2708,8 +2703,10 @@ interface OnToolCallStartEvent<TOOLS extends ToolSet = ToolSet> {
|
|
|
2708
2703
|
readonly callId: string;
|
|
2709
2704
|
/** Zero-based index of the current step where this tool call occurs. */
|
|
2710
2705
|
readonly stepNumber: number | undefined;
|
|
2711
|
-
/** The
|
|
2712
|
-
readonly
|
|
2706
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2707
|
+
readonly provider: string | undefined;
|
|
2708
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
2709
|
+
readonly modelId: string | undefined;
|
|
2713
2710
|
/** The full tool call object. */
|
|
2714
2711
|
readonly toolCall: TypedToolCall<TOOLS>;
|
|
2715
2712
|
/** The conversation messages available at tool execution time. */
|
|
@@ -2734,8 +2731,10 @@ type OnToolCallFinishEvent<TOOLS extends ToolSet = ToolSet> = {
|
|
|
2734
2731
|
readonly callId: string;
|
|
2735
2732
|
/** Zero-based index of the current step where this tool call occurred. */
|
|
2736
2733
|
readonly stepNumber: number | undefined;
|
|
2737
|
-
/** The
|
|
2738
|
-
readonly
|
|
2734
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2735
|
+
readonly provider: string | undefined;
|
|
2736
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
2737
|
+
readonly modelId: string | undefined;
|
|
2739
2738
|
/** The full tool call object. */
|
|
2740
2739
|
readonly toolCall: TypedToolCall<TOOLS>;
|
|
2741
2740
|
/** The conversation messages available at tool execution time. */
|
|
@@ -4620,8 +4619,10 @@ interface EmbedOnStartEvent {
|
|
|
4620
4619
|
readonly callId: string;
|
|
4621
4620
|
/** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
|
|
4622
4621
|
readonly operationId: string;
|
|
4623
|
-
/** The
|
|
4624
|
-
readonly
|
|
4622
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
4623
|
+
readonly provider: string;
|
|
4624
|
+
/** The specific model identifier (e.g., 'text-embedding-3-small'). */
|
|
4625
|
+
readonly modelId: string;
|
|
4625
4626
|
/** The value(s) being embedded. A string for embed, an array for embedMany. */
|
|
4626
4627
|
readonly value: string | Array<string>;
|
|
4627
4628
|
/** Maximum number of retries for failed requests. */
|
|
@@ -4653,8 +4654,10 @@ interface EmbedOnFinishEvent {
|
|
|
4653
4654
|
readonly callId: string;
|
|
4654
4655
|
/** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
|
|
4655
4656
|
readonly operationId: string;
|
|
4656
|
-
/** The
|
|
4657
|
-
readonly
|
|
4657
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
4658
|
+
readonly provider: string;
|
|
4659
|
+
/** The specific model identifier (e.g., 'text-embedding-3-small'). */
|
|
4660
|
+
readonly modelId: string;
|
|
4658
4661
|
/** The value(s) that were embedded. A string for embed, an array for embedMany. */
|
|
4659
4662
|
readonly value: string | Array<string>;
|
|
4660
4663
|
/** The resulting embedding(s). A single vector for embed, an array for embedMany. */
|
package/dist/index.d.ts
CHANGED
|
@@ -2541,15 +2541,6 @@ type TextStreamRawPart = {
|
|
|
2541
2541
|
};
|
|
2542
2542
|
type TextStreamPart<TOOLS extends ToolSet> = TextStreamTextStartPart | TextStreamTextEndPart | TextStreamTextDeltaPart | TextStreamReasoningStartPart | TextStreamReasoningEndPart | TextStreamReasoningDeltaPart | TextStreamCustomPart | TextStreamToolInputStartPart | TextStreamToolInputEndPart | TextStreamToolInputDeltaPart | TextStreamSourcePart | TextStreamFilePart | TextStreamReasoningFilePart | TextStreamToolCallPart<TOOLS> | TextStreamToolResultPart<TOOLS> | TextStreamToolErrorPart<TOOLS> | TextStreamToolOutputDeniedPart<TOOLS> | TextStreamToolApprovalRequestPart<TOOLS> | TextStreamStartStepPart | TextStreamFinishStepPart | TextStreamStartPart | TextStreamFinishPart | TextStreamAbortPart | TextStreamErrorPart | TextStreamRawPart;
|
|
2543
2543
|
|
|
2544
|
-
/**
|
|
2545
|
-
* Common model information used across callback events.
|
|
2546
|
-
*/
|
|
2547
|
-
interface ModelEventInfo {
|
|
2548
|
-
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2549
|
-
readonly provider: string;
|
|
2550
|
-
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
2551
|
-
readonly modelId: string;
|
|
2552
|
-
}
|
|
2553
2544
|
/**
|
|
2554
2545
|
* Event passed to the `onStart` callback.
|
|
2555
2546
|
*
|
|
@@ -2563,8 +2554,10 @@ interface OnStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output =
|
|
|
2563
2554
|
readonly callId: string;
|
|
2564
2555
|
/** Identifies the operation type (e.g. 'ai.generateText' or 'ai.streamText'). */
|
|
2565
2556
|
readonly operationId: string;
|
|
2566
|
-
/** The
|
|
2567
|
-
readonly
|
|
2557
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2558
|
+
readonly provider: string;
|
|
2559
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
2560
|
+
readonly modelId: string;
|
|
2568
2561
|
/** The system message(s) provided to the model. */
|
|
2569
2562
|
readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
|
|
2570
2563
|
/** The prompt string or array of messages if using the prompt option. */
|
|
@@ -2647,8 +2640,10 @@ interface OnStepStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Outpu
|
|
|
2647
2640
|
readonly callId: string;
|
|
2648
2641
|
/** Zero-based index of the current step. */
|
|
2649
2642
|
readonly stepNumber: number;
|
|
2650
|
-
/** The
|
|
2651
|
-
readonly
|
|
2643
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2644
|
+
readonly provider: string;
|
|
2645
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
2646
|
+
readonly modelId: string;
|
|
2652
2647
|
/**
|
|
2653
2648
|
* The system message for this step.
|
|
2654
2649
|
*/
|
|
@@ -2708,8 +2703,10 @@ interface OnToolCallStartEvent<TOOLS extends ToolSet = ToolSet> {
|
|
|
2708
2703
|
readonly callId: string;
|
|
2709
2704
|
/** Zero-based index of the current step where this tool call occurs. */
|
|
2710
2705
|
readonly stepNumber: number | undefined;
|
|
2711
|
-
/** The
|
|
2712
|
-
readonly
|
|
2706
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2707
|
+
readonly provider: string | undefined;
|
|
2708
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
2709
|
+
readonly modelId: string | undefined;
|
|
2713
2710
|
/** The full tool call object. */
|
|
2714
2711
|
readonly toolCall: TypedToolCall<TOOLS>;
|
|
2715
2712
|
/** The conversation messages available at tool execution time. */
|
|
@@ -2734,8 +2731,10 @@ type OnToolCallFinishEvent<TOOLS extends ToolSet = ToolSet> = {
|
|
|
2734
2731
|
readonly callId: string;
|
|
2735
2732
|
/** Zero-based index of the current step where this tool call occurred. */
|
|
2736
2733
|
readonly stepNumber: number | undefined;
|
|
2737
|
-
/** The
|
|
2738
|
-
readonly
|
|
2734
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
2735
|
+
readonly provider: string | undefined;
|
|
2736
|
+
/** The specific model identifier (e.g., 'gpt-4o'). */
|
|
2737
|
+
readonly modelId: string | undefined;
|
|
2739
2738
|
/** The full tool call object. */
|
|
2740
2739
|
readonly toolCall: TypedToolCall<TOOLS>;
|
|
2741
2740
|
/** The conversation messages available at tool execution time. */
|
|
@@ -4620,8 +4619,10 @@ interface EmbedOnStartEvent {
|
|
|
4620
4619
|
readonly callId: string;
|
|
4621
4620
|
/** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
|
|
4622
4621
|
readonly operationId: string;
|
|
4623
|
-
/** The
|
|
4624
|
-
readonly
|
|
4622
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
4623
|
+
readonly provider: string;
|
|
4624
|
+
/** The specific model identifier (e.g., 'text-embedding-3-small'). */
|
|
4625
|
+
readonly modelId: string;
|
|
4625
4626
|
/** The value(s) being embedded. A string for embed, an array for embedMany. */
|
|
4626
4627
|
readonly value: string | Array<string>;
|
|
4627
4628
|
/** Maximum number of retries for failed requests. */
|
|
@@ -4653,8 +4654,10 @@ interface EmbedOnFinishEvent {
|
|
|
4653
4654
|
readonly callId: string;
|
|
4654
4655
|
/** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
|
|
4655
4656
|
readonly operationId: string;
|
|
4656
|
-
/** The
|
|
4657
|
-
readonly
|
|
4657
|
+
/** The provider identifier (e.g., 'openai', 'anthropic'). */
|
|
4658
|
+
readonly provider: string;
|
|
4659
|
+
/** The specific model identifier (e.g., 'text-embedding-3-small'). */
|
|
4660
|
+
readonly modelId: string;
|
|
4658
4661
|
/** The value(s) that were embedded. A string for embed, an array for embedMany. */
|
|
4659
4662
|
readonly value: string | Array<string>;
|
|
4660
4663
|
/** The resulting embedding(s). A single vector for embed, an array for embedMany. */
|