@typia/vercel 12.0.0-dev.20260225 → 12.0.0-dev.20260227
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/README.md +46 -0
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
# `@typia/vercel`
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
[](https://github.com/samchon/typia/blob/master/LICENSE)
|
|
4
6
|
[](https://www.npmjs.com/package/typia)
|
|
5
7
|
[](https://www.npmjs.com/package/typia)
|
|
8
|
+
[](https://github.com/samchon/typia/actions?query=workflow%3Atest)
|
|
9
|
+
[](https://typia.io/docs/)
|
|
10
|
+
[](https://gurubase.io/g/typia)
|
|
11
|
+
[](https://discord.gg/E94XhzrUCZ)
|
|
6
12
|
|
|
7
13
|
[Vercel AI SDK](https://github.com/vercel/ai) integration for [`typia`](https://github.com/samchon/typia).
|
|
8
14
|
|
|
@@ -57,6 +63,46 @@ const tools: Record<string, Tool> = toVercelTools({
|
|
|
57
63
|
});
|
|
58
64
|
```
|
|
59
65
|
|
|
66
|
+
### Structured Output
|
|
67
|
+
|
|
68
|
+
Use `typia.llm.parameters<T>()` with Vercel's `jsonSchema()` to generate structured output with validation:
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { openai } from "@ai-sdk/openai";
|
|
72
|
+
import { generateObject, jsonSchema } from "ai";
|
|
73
|
+
import { dedent, stringifyValidationFailure } from "@typia/utils";
|
|
74
|
+
import typia, { tags } from "typia";
|
|
75
|
+
|
|
76
|
+
interface IMember {
|
|
77
|
+
email: string & tags.Format<"email">;
|
|
78
|
+
name: string;
|
|
79
|
+
age: number & tags.Minimum<0> & tags.Maximum<100>;
|
|
80
|
+
hobbies: string[];
|
|
81
|
+
joined_at: string & tags.Format<"date">;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const { object } = await generateObject({
|
|
85
|
+
model: openai("gpt-4o"),
|
|
86
|
+
schema: jsonSchema<IMember>(typia.llm.parameters<IMember>(), {
|
|
87
|
+
validate: (value) => {
|
|
88
|
+
const result = typia.validate<IMember>(value);
|
|
89
|
+
if (result.success) return { success: true, value: result.data };
|
|
90
|
+
return {
|
|
91
|
+
success: false,
|
|
92
|
+
error: new Error(stringifyValidationFailure(result)),
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
prompt: dedent`
|
|
97
|
+
I am a new member of the community.
|
|
98
|
+
|
|
99
|
+
My name is John Doe, and I am 25 years old.
|
|
100
|
+
I like playing basketball and reading books,
|
|
101
|
+
and joined to this community at 2022-01-01.
|
|
102
|
+
`,
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
60
106
|
## Features
|
|
61
107
|
|
|
62
108
|
- No manual schema definition — generates everything from TypeScript types or OpenAPI
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typia/vercel",
|
|
3
|
-
"version": "12.0.0-dev.
|
|
3
|
+
"version": "12.0.0-dev.20260227",
|
|
4
4
|
"description": "Vercel AI SDK integration for typia",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://typia.io",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@typia/interface": "^12.0.0-dev.
|
|
26
|
-
"@typia/utils": "^12.0.0-dev.
|
|
25
|
+
"@typia/interface": "^12.0.0-dev.20260227",
|
|
26
|
+
"@typia/utils": "^12.0.0-dev.20260227"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"ai": ">=4.0.0"
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
},
|
|
44
44
|
"sideEffects": false,
|
|
45
45
|
"files": [
|
|
46
|
-
"LICENSE",
|
|
47
46
|
"README.md",
|
|
48
47
|
"package.json",
|
|
49
48
|
"lib",
|