Skip to content

Commit c87511d

Browse files
authored
feat(utils): LlmJson.coerce for already json parsed SDKs. (#1769)
* feat(utils): `LlmJson.coerce` for already json parsed SDKs. * next version packaging. * fix something?
1 parent 5ee1136 commit c87511d

File tree

36 files changed

+93
-47
lines changed

36 files changed

+93
-47
lines changed

benchmark/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@typia/benchmark",
4-
"version": "12.0.0-dev.20260307",
4+
"version": "12.0.0-dev.20260307-2",
55
"description": "Benchmark program of typia performance",
66
"main": "bin/index.js",
77
"scripts": {

config/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@typia/config",
4-
"version": "12.0.0-dev.20260307",
4+
"version": "12.0.0-dev.20260307-2",
55
"description": "Shared build configuration for typia packages",
66
"devDependencies": {
77
"@rollup/plugin-commonjs": "catalog:rollup",

examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@typia/examples",
4-
"version": "12.0.0-dev.20260307",
4+
"version": "12.0.0-dev.20260307-2",
55
"description": "Example codes for typia website",
66
"scripts": {
77
"build": "rimraf bin && cross-env NODE_OPTIONS=\"--no-experimental-strip-types -r ts-node/register\" tsc && prettier --write bin/**/*.js",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@typia/station",
4-
"version": "12.0.0-dev.20260307",
4+
"version": "12.0.0-dev.20260307-2",
55
"description": "Typia Station",
66
"scripts": {
77
"build": "pnpm --filter=./packages/* -r build",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typia/core",
3-
"version": "12.0.0-dev.20260307",
3+
"version": "12.0.0-dev.20260307-2",
44
"description": "Superfast runtime validators with only one line",
55
"main": "src/index.ts",
66
"exports": {

packages/interface/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typia/interface",
3-
"version": "12.0.0-dev.20260307",
3+
"version": "12.0.0-dev.20260307-2",
44
"description": "Superfast runtime validators with only one line",
55
"main": "src/index.ts",
66
"exports": {

packages/interface/src/schema/ILlmFunction.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ export interface ILlmFunction {
8989
*
9090
* Type validation is NOT performed — use {@link validate} after parsing.
9191
*
92+
* If the SDK (e.g., LangChain, Vercel AI, MCP) already parses JSON internally
93+
* and provides a pre-parsed object, use `LlmJson.coerce()` from `@typia/utils`
94+
* instead to apply schema-based type coercion without re-parsing.
95+
*
9296
* @param str Raw JSON string from LLM output
9397
* @returns Parse result with data on success, or partial data with errors
9498
*/

packages/langchain/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typia/langchain",
3-
"version": "12.0.0-dev.20260307",
3+
"version": "12.0.0-dev.20260307-2",
44
"description": "LangChain.js integration for typia",
55
"main": "src/index.ts",
66
"exports": {

packages/langchain/src/internal/LangChainToolsRegistrar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ export namespace LangChainToolsRegistrar {
113113
description: entry.function.description ?? "",
114114
schema: passthroughSchema,
115115
func: async (args: unknown): Promise<string> => {
116+
const coerced: unknown = LlmJson.coerce(args, entry.function.parameters);
116117
const validation: IValidation<unknown> =
117-
entry.function.validate(args);
118+
entry.function.validate(coerced);
118119
if (!validation.success) {
119120
return LlmJson.stringify(validation);
120121
}

packages/mcp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typia/mcp",
3-
"version": "12.0.0-dev.20260307",
3+
"version": "12.0.0-dev.20260307-2",
44
"description": "MCP (Model Context Protocol) integration for typia",
55
"main": "src/index.ts",
66
"exports": {

0 commit comments

Comments
 (0)