ai 3.4.33 → 4.0.0-canary.0
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 +15 -0
- package/dist/index.d.mts +6 -474
- package/dist/index.d.ts +6 -474
- 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 -49
- 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/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.0",
|
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,9 +10,6 @@
|
|
10
10
|
"files": [
|
11
11
|
"dist/**/*",
|
12
12
|
"react/dist/**/*",
|
13
|
-
"svelte/dist/**/*",
|
14
|
-
"vue/dist/**/*",
|
15
|
-
"solid/dist/**/*",
|
16
13
|
"prompts/dist/**/*",
|
17
14
|
"rsc/dist/**/*",
|
18
15
|
"test/dist/**/*",
|
@@ -46,31 +43,13 @@
|
|
46
43
|
"react-server": "./react/dist/index.server.mjs",
|
47
44
|
"import": "./react/dist/index.mjs",
|
48
45
|
"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
46
|
}
|
65
47
|
},
|
66
48
|
"dependencies": {
|
67
49
|
"@ai-sdk/provider": "0.0.26",
|
68
50
|
"@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",
|
51
|
+
"@ai-sdk/react": "1.0.0-canary.0",
|
52
|
+
"@ai-sdk/ui-utils": "1.0.0-canary.0",
|
74
53
|
"@opentelemetry/api": "1.9.0",
|
75
54
|
"eventsource-parser": "1.1.2",
|
76
55
|
"jsondiffpatch": "0.6.0",
|
@@ -79,12 +58,7 @@
|
|
79
58
|
"zod-to-json-schema": "^3.23.3"
|
80
59
|
},
|
81
60
|
"devDependencies": {
|
82
|
-
"@anthropic-ai/sdk": "0.18.0",
|
83
|
-
"@aws-sdk/client-bedrock-runtime": "3.451.0",
|
84
61
|
"@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
62
|
"@testing-library/jest-dom": "^6.4.5",
|
89
63
|
"@testing-library/react": "^15.0.7",
|
90
64
|
"@testing-library/user-event": "^14.5.1",
|
@@ -93,15 +67,12 @@
|
|
93
67
|
"@types/react": "^18",
|
94
68
|
"@types/react-dom": "^18",
|
95
69
|
"@vitejs/plugin-react": "4.2.0",
|
96
|
-
"cohere-ai": "^7.6.2",
|
97
70
|
"eslint": "^7.32.0",
|
98
71
|
"jsdom": "^24.0.0",
|
99
|
-
"langchain": "0.0.196",
|
100
72
|
"msw": "2.3.1",
|
101
73
|
"openai": "4.52.6",
|
102
74
|
"react-dom": "^18",
|
103
75
|
"react-server-dom-webpack": "18.3.0-canary-eb33bd747-20240312",
|
104
|
-
"sswr": "2.1.0",
|
105
76
|
"tsup": "^7.2.0",
|
106
77
|
"typescript": "5.5.4",
|
107
78
|
"zod": "3.23.8",
|
@@ -111,9 +82,7 @@
|
|
111
82
|
"peerDependencies": {
|
112
83
|
"openai": "^4.42.0",
|
113
84
|
"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"
|
85
|
+
"zod": "^3.0.0"
|
117
86
|
},
|
118
87
|
"peerDependenciesMeta": {
|
119
88
|
"react": {
|
@@ -124,12 +93,6 @@
|
|
124
93
|
},
|
125
94
|
"openai": {
|
126
95
|
"optional": true
|
127
|
-
},
|
128
|
-
"sswr": {
|
129
|
-
"optional": true
|
130
|
-
},
|
131
|
-
"svelte": {
|
132
|
-
"optional": true
|
133
96
|
}
|
134
97
|
},
|
135
98
|
"engines": {
|
@@ -148,29 +111,28 @@
|
|
148
111
|
},
|
149
112
|
"keywords": [
|
150
113
|
"ai",
|
151
|
-
"
|
152
|
-
"svelte",
|
114
|
+
"vercel",
|
153
115
|
"react",
|
154
|
-
"
|
155
|
-
"
|
116
|
+
"next",
|
117
|
+
"nextjs"
|
156
118
|
],
|
157
119
|
"scripts": {
|
158
120
|
"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
|
121
|
+
"clean": "rm -rf dist && rm -rf react/dist && rm -rf rsc/dist",
|
160
122
|
"dev": "tsup --watch",
|
161
123
|
"lint": "eslint \"./**/*.ts*\"",
|
162
124
|
"type-check": "tsc --noEmit",
|
163
125
|
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
164
126
|
"test": "pnpm test:node && pnpm test:edge && pnpm test:ui && pnpm test:e2e",
|
127
|
+
"test:e2e": "playwright test",
|
165
128
|
"test:edge": "vitest --config vitest.edge.config.js --run",
|
129
|
+
"test:edge:watch": "vitest --config vitest.edge.config.js",
|
166
130
|
"test:node": "vitest --config vitest.node.config.js --run",
|
131
|
+
"test:node:watch": "vitest --config vitest.node.config.js",
|
167
132
|
"test:node:core": "pnpm vitest --config vitest.node.config.js --run ./core/",
|
168
133
|
"test:node:util": "pnpm vitest --config vitest.node.config.js --run ./util/",
|
169
134
|
"test:ui": "pnpm test:ui:react",
|
170
135
|
"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
136
|
"test:ui:react:watch": "vitest --config vitest.ui.react.config.js"
|
175
137
|
}
|
176
138
|
}
|
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 };
|