ai 3.4.33 → 4.0.0-canary.1
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 +28 -0
- package/dist/index.d.mts +7 -475
- package/dist/index.d.ts +7 -475
- package/dist/index.js +94 -771
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -746
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -55
- package/rsc/dist/index.d.ts +5 -67
- package/rsc/dist/rsc-server.d.mts +5 -67
- package/rsc/dist/rsc-server.mjs +19 -623
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/prompts/dist/index.d.mts +0 -220
- package/prompts/dist/index.d.ts +0 -220
- package/prompts/dist/index.js +0 -178
- package/prompts/dist/index.js.map +0 -1
- package/prompts/dist/index.mjs +0 -146
- package/prompts/dist/index.mjs.map +0 -1
- package/solid/dist/index.d.mts +0 -13
- package/solid/dist/index.d.ts +0 -13
- package/solid/dist/index.js +0 -35
- package/solid/dist/index.js.map +0 -1
- package/solid/dist/index.mjs +0 -12
- package/solid/dist/index.mjs.map +0 -1
- package/svelte/dist/index.d.mts +0 -175
- package/svelte/dist/index.d.ts +0 -175
- package/svelte/dist/index.js +0 -1161
- package/svelte/dist/index.js.map +0 -1
- package/svelte/dist/index.mjs +0 -1136
- package/svelte/dist/index.mjs.map +0 -1
- package/vue/dist/index.d.mts +0 -17
- package/vue/dist/index.d.ts +0 -17
- package/vue/dist/index.js +0 -38
- package/vue/dist/index.js.map +0 -1
- package/vue/dist/index.mjs +0 -15
- package/vue/dist/index.mjs.map +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ai",
|
3
|
-
"version": "
|
3
|
+
"version": "4.0.0-canary.1",
|
4
4
|
"description": "AI SDK by Vercel - The AI Toolkit for TypeScript and JavaScript",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"sideEffects": false,
|
@@ -10,10 +10,6 @@
|
|
10
10
|
"files": [
|
11
11
|
"dist/**/*",
|
12
12
|
"react/dist/**/*",
|
13
|
-
"svelte/dist/**/*",
|
14
|
-
"vue/dist/**/*",
|
15
|
-
"solid/dist/**/*",
|
16
|
-
"prompts/dist/**/*",
|
17
13
|
"rsc/dist/**/*",
|
18
14
|
"test/dist/**/*",
|
19
15
|
"CHANGELOG.md"
|
@@ -36,41 +32,18 @@
|
|
36
32
|
"react-server": "./rsc/dist/rsc-server.mjs",
|
37
33
|
"import": "./rsc/dist/rsc-client.mjs"
|
38
34
|
},
|
39
|
-
"./prompts": {
|
40
|
-
"types": "./prompts/dist/index.d.ts",
|
41
|
-
"import": "./prompts/dist/index.mjs",
|
42
|
-
"require": "./prompts/dist/index.js"
|
43
|
-
},
|
44
35
|
"./react": {
|
45
36
|
"types": "./react/dist/index.d.ts",
|
46
37
|
"react-server": "./react/dist/index.server.mjs",
|
47
38
|
"import": "./react/dist/index.mjs",
|
48
39
|
"require": "./react/dist/index.js"
|
49
|
-
},
|
50
|
-
"./svelte": {
|
51
|
-
"types": "./svelte/dist/index.d.ts",
|
52
|
-
"import": "./svelte/dist/index.mjs",
|
53
|
-
"require": "./svelte/dist/index.js"
|
54
|
-
},
|
55
|
-
"./vue": {
|
56
|
-
"types": "./vue/dist/index.d.ts",
|
57
|
-
"import": "./vue/dist/index.mjs",
|
58
|
-
"require": "./vue/dist/index.js"
|
59
|
-
},
|
60
|
-
"./solid": {
|
61
|
-
"types": "./solid/dist/index.d.ts",
|
62
|
-
"import": "./solid/dist/index.mjs",
|
63
|
-
"require": "./solid/dist/index.js"
|
64
40
|
}
|
65
41
|
},
|
66
42
|
"dependencies": {
|
67
43
|
"@ai-sdk/provider": "0.0.26",
|
68
44
|
"@ai-sdk/provider-utils": "1.0.22",
|
69
|
-
"@ai-sdk/react": "0.0.
|
70
|
-
"@ai-sdk/
|
71
|
-
"@ai-sdk/svelte": "0.0.57",
|
72
|
-
"@ai-sdk/ui-utils": "0.0.50",
|
73
|
-
"@ai-sdk/vue": "0.0.59",
|
45
|
+
"@ai-sdk/react": "1.0.0-canary.1",
|
46
|
+
"@ai-sdk/ui-utils": "1.0.0-canary.1",
|
74
47
|
"@opentelemetry/api": "1.9.0",
|
75
48
|
"eventsource-parser": "1.1.2",
|
76
49
|
"jsondiffpatch": "0.6.0",
|
@@ -79,12 +52,7 @@
|
|
79
52
|
"zod-to-json-schema": "^3.23.3"
|
80
53
|
},
|
81
54
|
"devDependencies": {
|
82
|
-
"@anthropic-ai/sdk": "0.18.0",
|
83
|
-
"@aws-sdk/client-bedrock-runtime": "3.451.0",
|
84
55
|
"@edge-runtime/vm": "^3.2.0",
|
85
|
-
"@google/generative-ai": "0.1.1",
|
86
|
-
"@huggingface/inference": "2.6.4",
|
87
|
-
"@mistralai/mistralai": "0.1.3",
|
88
56
|
"@testing-library/jest-dom": "^6.4.5",
|
89
57
|
"@testing-library/react": "^15.0.7",
|
90
58
|
"@testing-library/user-event": "^14.5.1",
|
@@ -93,15 +61,12 @@
|
|
93
61
|
"@types/react": "^18",
|
94
62
|
"@types/react-dom": "^18",
|
95
63
|
"@vitejs/plugin-react": "4.2.0",
|
96
|
-
"cohere-ai": "^7.6.2",
|
97
64
|
"eslint": "^7.32.0",
|
98
65
|
"jsdom": "^24.0.0",
|
99
|
-
"langchain": "0.0.196",
|
100
66
|
"msw": "2.3.1",
|
101
67
|
"openai": "4.52.6",
|
102
68
|
"react-dom": "^18",
|
103
69
|
"react-server-dom-webpack": "18.3.0-canary-eb33bd747-20240312",
|
104
|
-
"sswr": "2.1.0",
|
105
70
|
"tsup": "^7.2.0",
|
106
71
|
"typescript": "5.5.4",
|
107
72
|
"zod": "3.23.8",
|
@@ -111,9 +76,7 @@
|
|
111
76
|
"peerDependencies": {
|
112
77
|
"openai": "^4.42.0",
|
113
78
|
"react": "^18 || ^19 || ^19.0.0-rc",
|
114
|
-
"zod": "^3.0.0"
|
115
|
-
"sswr": "^2.1.0",
|
116
|
-
"svelte": "^3.0.0 || ^4.0.0 || ^5.0.0"
|
79
|
+
"zod": "^3.0.0"
|
117
80
|
},
|
118
81
|
"peerDependenciesMeta": {
|
119
82
|
"react": {
|
@@ -124,12 +87,6 @@
|
|
124
87
|
},
|
125
88
|
"openai": {
|
126
89
|
"optional": true
|
127
|
-
},
|
128
|
-
"sswr": {
|
129
|
-
"optional": true
|
130
|
-
},
|
131
|
-
"svelte": {
|
132
|
-
"optional": true
|
133
90
|
}
|
134
91
|
},
|
135
92
|
"engines": {
|
@@ -148,29 +105,28 @@
|
|
148
105
|
},
|
149
106
|
"keywords": [
|
150
107
|
"ai",
|
151
|
-
"
|
152
|
-
"svelte",
|
108
|
+
"vercel",
|
153
109
|
"react",
|
154
|
-
"
|
155
|
-
"
|
110
|
+
"next",
|
111
|
+
"nextjs"
|
156
112
|
],
|
157
113
|
"scripts": {
|
158
114
|
"build": "tsup && cat react/dist/index.server.d.ts >> react/dist/index.d.ts",
|
159
|
-
"clean": "rm -rf dist && rm -rf react/dist && rm -rf
|
115
|
+
"clean": "rm -rf dist && rm -rf react/dist && rm -rf rsc/dist",
|
160
116
|
"dev": "tsup --watch",
|
161
117
|
"lint": "eslint \"./**/*.ts*\"",
|
162
118
|
"type-check": "tsc --noEmit",
|
163
119
|
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
164
120
|
"test": "pnpm test:node && pnpm test:edge && pnpm test:ui && pnpm test:e2e",
|
121
|
+
"test:e2e": "playwright test",
|
165
122
|
"test:edge": "vitest --config vitest.edge.config.js --run",
|
123
|
+
"test:edge:watch": "vitest --config vitest.edge.config.js",
|
166
124
|
"test:node": "vitest --config vitest.node.config.js --run",
|
125
|
+
"test:node:watch": "vitest --config vitest.node.config.js",
|
167
126
|
"test:node:core": "pnpm vitest --config vitest.node.config.js --run ./core/",
|
168
127
|
"test:node:util": "pnpm vitest --config vitest.node.config.js --run ./util/",
|
169
128
|
"test:ui": "pnpm test:ui:react",
|
170
129
|
"test:ui:react": "vitest --config vitest.ui.react.config.js --run",
|
171
|
-
"test:e2e": "playwright test",
|
172
|
-
"test:edge:watch": "vitest --config vitest.edge.config.js",
|
173
|
-
"test:node:watch": "vitest --config vitest.node.config.js",
|
174
130
|
"test:ui:react:watch": "vitest --config vitest.ui.react.config.js"
|
175
131
|
}
|
176
132
|
}
|
package/rsc/dist/index.d.ts
CHANGED
@@ -2,7 +2,6 @@ import { LanguageModelV1FinishReason, LanguageModelV1CallWarning, LanguageModelV
|
|
2
2
|
import { ReactNode } from 'react';
|
3
3
|
import { z } from 'zod';
|
4
4
|
import { ToolInvocation, Attachment } from '@ai-sdk/ui-utils';
|
5
|
-
import OpenAI from 'openai';
|
6
5
|
|
7
6
|
type AIAction<T = any, R = any> = (...args: T[]) => Promise<R>;
|
8
7
|
type AIActions<T = any, R = any> = Record<string, AIAction<T, R>>;
|
@@ -463,12 +462,12 @@ type Prompt = {
|
|
463
462
|
messages?: Array<CoreMessage> | Array<UIMessage>;
|
464
463
|
};
|
465
464
|
|
466
|
-
type Streamable
|
467
|
-
type Renderer
|
465
|
+
type Streamable = ReactNode | Promise<ReactNode>;
|
466
|
+
type Renderer<T extends Array<any>> = (...args: T) => Streamable | Generator<Streamable, Streamable, void> | AsyncGenerator<Streamable, Streamable, void>;
|
468
467
|
type RenderTool<PARAMETERS extends z.ZodTypeAny = any> = {
|
469
468
|
description?: string;
|
470
469
|
parameters: PARAMETERS;
|
471
|
-
generate?: Renderer
|
470
|
+
generate?: Renderer<[
|
472
471
|
z.infer<PARAMETERS>,
|
473
472
|
{
|
474
473
|
toolName: string;
|
@@ -476,7 +475,7 @@ type RenderTool<PARAMETERS extends z.ZodTypeAny = any> = {
|
|
476
475
|
}
|
477
476
|
]>;
|
478
477
|
};
|
479
|
-
type RenderText = Renderer
|
478
|
+
type RenderText = Renderer<[
|
480
479
|
{
|
481
480
|
/**
|
482
481
|
* The full text content from the model so far.
|
@@ -556,67 +555,6 @@ functionality that can be fully encapsulated in the provider.
|
|
556
555
|
}) => Promise<void> | void;
|
557
556
|
}): Promise<RenderResult>;
|
558
557
|
|
559
|
-
type Streamable = ReactNode | Promise<ReactNode>;
|
560
|
-
type Renderer<T> = (props: T) => Streamable | Generator<Streamable, Streamable, void> | AsyncGenerator<Streamable, Streamable, void>;
|
561
|
-
/**
|
562
|
-
* `render` is a helper function to create a streamable UI from some LLMs.
|
563
|
-
* This API only supports OpenAI's GPT models with Function Calling and Assistants Tools,
|
564
|
-
* please use `streamUI` for compatibility with other providers.
|
565
|
-
*
|
566
|
-
* @deprecated It's recommended to use the `streamUI` API for compatibility with AI SDK Core APIs
|
567
|
-
* and future features. This API will be removed in a future release.
|
568
|
-
*/
|
569
|
-
declare function render<TS extends {
|
570
|
-
[name: string]: z.Schema;
|
571
|
-
} = {}, FS extends {
|
572
|
-
[name: string]: z.Schema;
|
573
|
-
} = {}>(options: {
|
574
|
-
/**
|
575
|
-
* The model name to use. Must be OpenAI SDK compatible. Tools and Functions are only supported
|
576
|
-
* GPT models (3.5/4), OpenAI Assistants, Mistral small and large, and Fireworks firefunction-v1.
|
577
|
-
*
|
578
|
-
* @example "gpt-3.5-turbo"
|
579
|
-
*/
|
580
|
-
model: string;
|
581
|
-
/**
|
582
|
-
* The provider instance to use. Currently the only provider available is OpenAI.
|
583
|
-
* This needs to match the model name.
|
584
|
-
*/
|
585
|
-
provider: OpenAI;
|
586
|
-
messages: Parameters<typeof OpenAI.prototype.chat.completions.create>[0]['messages'];
|
587
|
-
text?: Renderer<{
|
588
|
-
/**
|
589
|
-
* The full text content from the model so far.
|
590
|
-
*/
|
591
|
-
content: string;
|
592
|
-
/**
|
593
|
-
* The new appended text content from the model since the last `text` call.
|
594
|
-
*/
|
595
|
-
delta: string;
|
596
|
-
/**
|
597
|
-
* Whether the model is done generating text.
|
598
|
-
* If `true`, the `content` will be the final output and this call will be the last.
|
599
|
-
*/
|
600
|
-
done: boolean;
|
601
|
-
}>;
|
602
|
-
tools?: {
|
603
|
-
[name in keyof TS]: {
|
604
|
-
description?: string;
|
605
|
-
parameters: TS[name];
|
606
|
-
render: Renderer<z.infer<TS[name]>>;
|
607
|
-
};
|
608
|
-
};
|
609
|
-
functions?: {
|
610
|
-
[name in keyof FS]: {
|
611
|
-
description?: string;
|
612
|
-
parameters: FS[name];
|
613
|
-
render: Renderer<z.infer<FS[name]>>;
|
614
|
-
};
|
615
|
-
};
|
616
|
-
initial?: ReactNode;
|
617
|
-
temperature?: number;
|
618
|
-
}): ReactNode;
|
619
|
-
|
620
558
|
type StreamableUIWrapper = {
|
621
559
|
/**
|
622
560
|
* The value of the streamable UI. This can be returned from a Server Action and received by the client.
|
@@ -782,4 +720,4 @@ declare function useAIState<AI extends AIProvider = any>(key: keyof InferAIState
|
|
782
720
|
declare function useActions<AI extends AIProvider = any>(): InferActions<AI, any>;
|
783
721
|
declare function useSyncUIState(): () => Promise<void>;
|
784
722
|
|
785
|
-
export { StreamableValue, createAI, createStreamableUI, createStreamableValue, getAIState, getMutableAIState, readStreamableValue,
|
723
|
+
export { StreamableValue, createAI, createStreamableUI, createStreamableValue, getAIState, getMutableAIState, readStreamableValue, streamUI, useAIState, useActions, useStreamableValue, useSyncUIState, useUIState };
|
@@ -2,7 +2,6 @@ import { LanguageModelV1FinishReason, LanguageModelV1CallWarning, LanguageModelV
|
|
2
2
|
import { ReactNode } from 'react';
|
3
3
|
import { z } from 'zod';
|
4
4
|
import { ToolInvocation, Attachment } from '@ai-sdk/ui-utils';
|
5
|
-
import OpenAI from 'openai';
|
6
5
|
|
7
6
|
type AIAction<T = any, R = any> = (...args: T[]) => Promise<R>;
|
8
7
|
type AIActions<T = any, R = any> = Record<string, AIAction<T, R>>;
|
@@ -461,12 +460,12 @@ type Prompt = {
|
|
461
460
|
messages?: Array<CoreMessage> | Array<UIMessage>;
|
462
461
|
};
|
463
462
|
|
464
|
-
type Streamable
|
465
|
-
type Renderer
|
463
|
+
type Streamable = ReactNode | Promise<ReactNode>;
|
464
|
+
type Renderer<T extends Array<any>> = (...args: T) => Streamable | Generator<Streamable, Streamable, void> | AsyncGenerator<Streamable, Streamable, void>;
|
466
465
|
type RenderTool<PARAMETERS extends z.ZodTypeAny = any> = {
|
467
466
|
description?: string;
|
468
467
|
parameters: PARAMETERS;
|
469
|
-
generate?: Renderer
|
468
|
+
generate?: Renderer<[
|
470
469
|
z.infer<PARAMETERS>,
|
471
470
|
{
|
472
471
|
toolName: string;
|
@@ -474,7 +473,7 @@ type RenderTool<PARAMETERS extends z.ZodTypeAny = any> = {
|
|
474
473
|
}
|
475
474
|
]>;
|
476
475
|
};
|
477
|
-
type RenderText = Renderer
|
476
|
+
type RenderText = Renderer<[
|
478
477
|
{
|
479
478
|
/**
|
480
479
|
* The full text content from the model so far.
|
@@ -554,67 +553,6 @@ functionality that can be fully encapsulated in the provider.
|
|
554
553
|
}) => Promise<void> | void;
|
555
554
|
}): Promise<RenderResult>;
|
556
555
|
|
557
|
-
type Streamable = ReactNode | Promise<ReactNode>;
|
558
|
-
type Renderer<T> = (props: T) => Streamable | Generator<Streamable, Streamable, void> | AsyncGenerator<Streamable, Streamable, void>;
|
559
|
-
/**
|
560
|
-
* `render` is a helper function to create a streamable UI from some LLMs.
|
561
|
-
* This API only supports OpenAI's GPT models with Function Calling and Assistants Tools,
|
562
|
-
* please use `streamUI` for compatibility with other providers.
|
563
|
-
*
|
564
|
-
* @deprecated It's recommended to use the `streamUI` API for compatibility with AI SDK Core APIs
|
565
|
-
* and future features. This API will be removed in a future release.
|
566
|
-
*/
|
567
|
-
declare function render<TS extends {
|
568
|
-
[name: string]: z.Schema;
|
569
|
-
} = {}, FS extends {
|
570
|
-
[name: string]: z.Schema;
|
571
|
-
} = {}>(options: {
|
572
|
-
/**
|
573
|
-
* The model name to use. Must be OpenAI SDK compatible. Tools and Functions are only supported
|
574
|
-
* GPT models (3.5/4), OpenAI Assistants, Mistral small and large, and Fireworks firefunction-v1.
|
575
|
-
*
|
576
|
-
* @example "gpt-3.5-turbo"
|
577
|
-
*/
|
578
|
-
model: string;
|
579
|
-
/**
|
580
|
-
* The provider instance to use. Currently the only provider available is OpenAI.
|
581
|
-
* This needs to match the model name.
|
582
|
-
*/
|
583
|
-
provider: OpenAI;
|
584
|
-
messages: Parameters<typeof OpenAI.prototype.chat.completions.create>[0]['messages'];
|
585
|
-
text?: Renderer<{
|
586
|
-
/**
|
587
|
-
* The full text content from the model so far.
|
588
|
-
*/
|
589
|
-
content: string;
|
590
|
-
/**
|
591
|
-
* The new appended text content from the model since the last `text` call.
|
592
|
-
*/
|
593
|
-
delta: string;
|
594
|
-
/**
|
595
|
-
* Whether the model is done generating text.
|
596
|
-
* If `true`, the `content` will be the final output and this call will be the last.
|
597
|
-
*/
|
598
|
-
done: boolean;
|
599
|
-
}>;
|
600
|
-
tools?: {
|
601
|
-
[name in keyof TS]: {
|
602
|
-
description?: string;
|
603
|
-
parameters: TS[name];
|
604
|
-
render: Renderer<z.infer<TS[name]>>;
|
605
|
-
};
|
606
|
-
};
|
607
|
-
functions?: {
|
608
|
-
[name in keyof FS]: {
|
609
|
-
description?: string;
|
610
|
-
parameters: FS[name];
|
611
|
-
render: Renderer<z.infer<FS[name]>>;
|
612
|
-
};
|
613
|
-
};
|
614
|
-
initial?: ReactNode;
|
615
|
-
temperature?: number;
|
616
|
-
}): ReactNode;
|
617
|
-
|
618
556
|
type StreamableUIWrapper = {
|
619
557
|
/**
|
620
558
|
* The value of the streamable UI. This can be returned from a Server Action and received by the client.
|
@@ -717,4 +655,4 @@ type StreamableValueWrapper<T, E> = {
|
|
717
655
|
done(...args: [T] | []): StreamableValueWrapper<T, E>;
|
718
656
|
};
|
719
657
|
|
720
|
-
export { createAI, createStreamableUI, createStreamableValue, getAIState, getMutableAIState,
|
658
|
+
export { createAI, createStreamableUI, createStreamableValue, getAIState, getMutableAIState, streamUI };
|