You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each `ILlmFunction` includes a `parse()` method for handling LLM JSON outputs. This parser is specifically designed for the messy reality of LLM responses:
- Junk text prefix skipping (explanatory text LLMs often add)
135
+
136
+
**Type Coercion:**
137
+
138
+
LLMs frequently return wrong types — numbers as strings, booleans as strings, or even double-stringified JSON objects. `func.parse()` automatically coerces these based on the function's parameter schema.
139
+
140
+
<Callouttype="warning">
141
+
**0% → 100% Success Rate on Union Types**
142
+
143
+
`Qwen3.5` model shows 0% success rate when handling union types with double-stringified JSON objects. With `func.parse()` type coercion, the success rate jumps to 100%.
144
+
</Callout>
145
+
146
+
<Callouttype="info">
147
+
**For Pre-parsed Objects, Use `func.coerce()`**
148
+
149
+
Some LLM SDKs (Anthropic, Vercel AI, LangChain, MCP) parse JSON internally and return JavaScript objects directly. In these cases, use `func.coerce()` instead of `func.parse()` to fix types without re-parsing.
150
+
151
+
For more details, see [JSON Utilities](./json).
152
+
</Callout>
153
+
118
154
## Validation Feedback
119
155
120
-
`typia.llm.application<App>()` embeds [`typia.validate<T>()`](/docs/validators/validate) in every function for automatic argument validation. When validation fails, the error is returned as text content with inline `// ❌` comments at each invalid property:
`typia.llm.application<App>()` embeds [`typia.validate<T>()`](/docs/validators/validate) in every function for automatic argument validation. When validation fails, use `LlmJson.stringify()` from `@typia/utils` to format errors with inline `// ❌` comments:
0 commit comments