ai 2.1.11 → 2.1.12
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/package.json +5 -4
- package/react/dist/index.d.ts +5 -2
- package/react/dist/index.js +0 -26
- package/react/dist/index.mjs +0 -25
- package/react/dist/index.server.d.ts +15 -0
- package/react/dist/index.server.js +73 -0
- package/react/dist/index.server.mjs +47 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ai",
|
3
|
-
"version": "2.1.
|
3
|
+
"version": "2.1.12",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"sideEffects": false,
|
6
6
|
"main": "./dist/index.js",
|
@@ -22,6 +22,7 @@
|
|
22
22
|
},
|
23
23
|
"./react": {
|
24
24
|
"types": "./react/dist/index.d.ts",
|
25
|
+
"react-server": "./react/dist/index.server.mjs",
|
25
26
|
"import": "./react/dist/index.mjs",
|
26
27
|
"module": "./react/dist/index.mjs",
|
27
28
|
"require": "./react/dist/index.js"
|
@@ -62,8 +63,8 @@
|
|
62
63
|
"ts-jest": "29.0.3",
|
63
64
|
"tsup": "^6.7.0",
|
64
65
|
"typescript": "5.1.3",
|
65
|
-
"
|
66
|
-
"
|
66
|
+
"eslint-config-vercel-ai": "0.0.0",
|
67
|
+
"@vercel/ai-tsconfig": "0.0.0"
|
67
68
|
},
|
68
69
|
"peerDependencies": {
|
69
70
|
"react": "^18.2.0",
|
@@ -88,7 +89,7 @@
|
|
88
89
|
"access": "public"
|
89
90
|
},
|
90
91
|
"scripts": {
|
91
|
-
"build": "tsup",
|
92
|
+
"build": "tsup && cat react/dist/index.server.d.ts >> react/dist/index.d.ts",
|
92
93
|
"clean": "rm -rf dist && rm -rf react/dist && rm -rf svelte/dist && rm -rf vue/dist",
|
93
94
|
"dev": "tsup --watch",
|
94
95
|
"lint": "eslint \"./**/*.ts*\"",
|
package/react/dist/index.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { ChatCompletionRequestMessageFunctionCall, CreateChatCompletionRequestFunctionCall } from 'openai-edge';
|
2
2
|
import { ChatCompletionFunctions } from 'openai-edge/types/api';
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
3
|
|
5
4
|
/**
|
6
5
|
* Shared types between the API and UI packages.
|
@@ -252,6 +251,9 @@ type UseCompletionHelpers = {
|
|
252
251
|
};
|
253
252
|
declare function useCompletion({ api, id, initialCompletion, initialInput, credentials, headers, body, onResponse, onFinish, onError }?: UseCompletionOptions): UseCompletionHelpers;
|
254
253
|
|
254
|
+
export { CreateMessage, Message, UseChatHelpers, UseChatOptions, UseCompletionHelpers, useChat, useCompletion };
|
255
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
256
|
+
|
255
257
|
type Props = {
|
256
258
|
/**
|
257
259
|
* A ReadableStream produced by the AI SDK.
|
@@ -260,7 +262,8 @@ type Props = {
|
|
260
262
|
};
|
261
263
|
/**
|
262
264
|
* A React Server Component that recursively renders a stream of tokens.
|
265
|
+
* Can only be used inside of server components.
|
263
266
|
*/
|
264
267
|
declare function Tokens(props: Props): Promise<react_jsx_runtime.JSX.Element>;
|
265
268
|
|
266
|
-
export {
|
269
|
+
export { Tokens };
|
package/react/dist/index.js
CHANGED
@@ -65,7 +65,6 @@ var __async = (__this, __arguments, generator) => {
|
|
65
65
|
// react/index.ts
|
66
66
|
var react_exports = {};
|
67
67
|
__export(react_exports, {
|
68
|
-
Tokens: () => Tokens,
|
69
68
|
useChat: () => useChat,
|
70
69
|
useCompletion: () => useCompletion
|
71
70
|
});
|
@@ -497,33 +496,8 @@ function useCompletion({
|
|
497
496
|
isLoading: isMutating
|
498
497
|
};
|
499
498
|
}
|
500
|
-
|
501
|
-
// react/tokens.tsx
|
502
|
-
var import_react3 = require("react");
|
503
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
504
|
-
function Tokens(props) {
|
505
|
-
return __async(this, null, function* () {
|
506
|
-
const { stream } = props;
|
507
|
-
const reader = stream.getReader();
|
508
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.Suspense, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecursiveTokens, { reader }) });
|
509
|
-
});
|
510
|
-
}
|
511
|
-
function RecursiveTokens(_0) {
|
512
|
-
return __async(this, arguments, function* ({ reader }) {
|
513
|
-
const { done, value } = yield reader.read();
|
514
|
-
if (done) {
|
515
|
-
return null;
|
516
|
-
}
|
517
|
-
const text = new TextDecoder().decode(value);
|
518
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
519
|
-
text,
|
520
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecursiveTokens, { reader }) })
|
521
|
-
] });
|
522
|
-
});
|
523
|
-
}
|
524
499
|
// Annotate the CommonJS export names for ESM import in node:
|
525
500
|
0 && (module.exports = {
|
526
|
-
Tokens,
|
527
501
|
useChat,
|
528
502
|
useCompletion
|
529
503
|
});
|
package/react/dist/index.mjs
CHANGED
@@ -462,32 +462,7 @@ function useCompletion({
|
|
462
462
|
isLoading: isMutating
|
463
463
|
};
|
464
464
|
}
|
465
|
-
|
466
|
-
// react/tokens.tsx
|
467
|
-
import { Suspense } from "react";
|
468
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
469
|
-
function Tokens(props) {
|
470
|
-
return __async(this, null, function* () {
|
471
|
-
const { stream } = props;
|
472
|
-
const reader = stream.getReader();
|
473
|
-
return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(RecursiveTokens, { reader }) });
|
474
|
-
});
|
475
|
-
}
|
476
|
-
function RecursiveTokens(_0) {
|
477
|
-
return __async(this, arguments, function* ({ reader }) {
|
478
|
-
const { done, value } = yield reader.read();
|
479
|
-
if (done) {
|
480
|
-
return null;
|
481
|
-
}
|
482
|
-
const text = new TextDecoder().decode(value);
|
483
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
484
|
-
text,
|
485
|
-
/* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(RecursiveTokens, { reader }) })
|
486
|
-
] });
|
487
|
-
});
|
488
|
-
}
|
489
465
|
export {
|
490
|
-
Tokens,
|
491
466
|
useChat,
|
492
467
|
useCompletion
|
493
468
|
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
+
|
3
|
+
type Props = {
|
4
|
+
/**
|
5
|
+
* A ReadableStream produced by the AI SDK.
|
6
|
+
*/
|
7
|
+
stream: ReadableStream;
|
8
|
+
};
|
9
|
+
/**
|
10
|
+
* A React Server Component that recursively renders a stream of tokens.
|
11
|
+
* Can only be used inside of server components.
|
12
|
+
*/
|
13
|
+
declare function Tokens(props: Props): Promise<react_jsx_runtime.JSX.Element>;
|
14
|
+
|
15
|
+
export { Tokens };
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var __async = (__this, __arguments, generator) => {
|
20
|
+
return new Promise((resolve, reject) => {
|
21
|
+
var fulfilled = (value) => {
|
22
|
+
try {
|
23
|
+
step(generator.next(value));
|
24
|
+
} catch (e) {
|
25
|
+
reject(e);
|
26
|
+
}
|
27
|
+
};
|
28
|
+
var rejected = (value) => {
|
29
|
+
try {
|
30
|
+
step(generator.throw(value));
|
31
|
+
} catch (e) {
|
32
|
+
reject(e);
|
33
|
+
}
|
34
|
+
};
|
35
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
36
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
37
|
+
});
|
38
|
+
};
|
39
|
+
|
40
|
+
// react/index.server.ts
|
41
|
+
var index_server_exports = {};
|
42
|
+
__export(index_server_exports, {
|
43
|
+
Tokens: () => Tokens
|
44
|
+
});
|
45
|
+
module.exports = __toCommonJS(index_server_exports);
|
46
|
+
|
47
|
+
// react/tokens.tsx
|
48
|
+
var import_react = require("react");
|
49
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
50
|
+
function Tokens(props) {
|
51
|
+
return __async(this, null, function* () {
|
52
|
+
const { stream } = props;
|
53
|
+
const reader = stream.getReader();
|
54
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecursiveTokens, { reader }) });
|
55
|
+
});
|
56
|
+
}
|
57
|
+
function RecursiveTokens(_0) {
|
58
|
+
return __async(this, arguments, function* ({ reader }) {
|
59
|
+
const { done, value } = yield reader.read();
|
60
|
+
if (done) {
|
61
|
+
return null;
|
62
|
+
}
|
63
|
+
const text = new TextDecoder().decode(value);
|
64
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
65
|
+
text,
|
66
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RecursiveTokens, { reader }) })
|
67
|
+
] });
|
68
|
+
});
|
69
|
+
}
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
71
|
+
0 && (module.exports = {
|
72
|
+
Tokens
|
73
|
+
});
|
@@ -0,0 +1,47 @@
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
2
|
+
return new Promise((resolve, reject) => {
|
3
|
+
var fulfilled = (value) => {
|
4
|
+
try {
|
5
|
+
step(generator.next(value));
|
6
|
+
} catch (e) {
|
7
|
+
reject(e);
|
8
|
+
}
|
9
|
+
};
|
10
|
+
var rejected = (value) => {
|
11
|
+
try {
|
12
|
+
step(generator.throw(value));
|
13
|
+
} catch (e) {
|
14
|
+
reject(e);
|
15
|
+
}
|
16
|
+
};
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
19
|
+
});
|
20
|
+
};
|
21
|
+
|
22
|
+
// react/tokens.tsx
|
23
|
+
import { Suspense } from "react";
|
24
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
25
|
+
function Tokens(props) {
|
26
|
+
return __async(this, null, function* () {
|
27
|
+
const { stream } = props;
|
28
|
+
const reader = stream.getReader();
|
29
|
+
return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(RecursiveTokens, { reader }) });
|
30
|
+
});
|
31
|
+
}
|
32
|
+
function RecursiveTokens(_0) {
|
33
|
+
return __async(this, arguments, function* ({ reader }) {
|
34
|
+
const { done, value } = yield reader.read();
|
35
|
+
if (done) {
|
36
|
+
return null;
|
37
|
+
}
|
38
|
+
const text = new TextDecoder().decode(value);
|
39
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
40
|
+
text,
|
41
|
+
/* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(RecursiveTokens, { reader }) })
|
42
|
+
] });
|
43
|
+
});
|
44
|
+
}
|
45
|
+
export {
|
46
|
+
Tokens
|
47
|
+
};
|