fix(typia): do not import @typia/utils from transformer.#1830
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the transformer/runtime dependency on @typia/utils for LLM schema generation by moving JSON-schema→LLM-schema conversion fully into the native (Go) compiler pipeline, while also adding/refining strict conversion behavior and expanding test coverage to validate the new outputs.
Changes:
- Refactors LLM schema/parameters generation to emit literal schemas (no runtime
@typia/utilsconverter /__typia_utilsalias). - Adds “strict” conversion behavior (shifting certain constraints into
description, cascading ref property docs to owner, etc.). - Adds new fixture + test suites to validate parameter/application/schema conversion and ensure no
@typia/utilsimport appears in emitted output.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
packages/typia/native/core/programmers/llm/LlmSchemaProgrammer.go |
Replaces runtime converter usage with compile-time conversion + strict-mode shaping and $defs population. |
packages/typia/native/core/programmers/llm/LlmParametersProgrammer.go |
Emits parameters schema as a literal converted value (no runtime conversion/import). |
packages/typia/native/core/programmers/llm/LlmApplicationProgrammer.go |
Unifies application parameter/output conversion via shared conversion helper. |
packages/typia/native/adapter/cleanup.go |
Removes special casing for __typia_utils runtime alias/import injection. |
tests/test-typia-ttsc/src/features/test_emit_llm_schema_no_utils_import.ts |
Ensures emitted JS has no @typia/utils, __typia_utils, or converter symbol references. |
tests/test-typia-ttsc/fixtures/llm-schema/tsconfig.json |
Adds a dedicated fixture tsconfig for the new emit test. |
tests/test-typia-ttsc/fixtures/llm-schema/src/main.ts |
Fixture source that emits typia.llm.schema + typia.llm.parameters. |
tests/test-typia-schema/src/features/llm.schema/test_llm_schema_converter_matrix.ts |
Adds matrix coverage for non-strict schema conversion. |
tests/test-typia-schema/src/features/llm.schema/test_llm_schema_strict_converter_matrix.ts |
Adds matrix coverage for strict-mode shifting/cascading behavior. |
tests/test-typia-schema/src/features/llm.schema/test_llm_schema_spec_atomic.ts |
Adds atomic-type schema spec tests. |
tests/test-typia-schema/src/features/llm.schema/test_llm_schema_spec_composite.ts |
Adds composite-type schema spec tests (object/record/ref/union/arrays). |
tests/test-typia-schema/src/features/llm.schema/test_llm_schema_spec_strict.ts |
Adds strict-mode spec tests for string/number/array/object shifting/cascading. |
tests/test-typia-schema/src/features/llm.parameters/test_llm_parameters_converter_matrix.ts |
Adds matrix coverage for parameters conversion behavior. |
tests/test-typia-schema/src/features/llm.parameters/test_llm_parameters_spec_properties.ts |
Adds spec coverage for parameters property conversion and $defs behavior. |
tests/test-typia-schema/src/features/llm.application/test_llm_application_schema_converter_matrix.ts |
Adds matrix coverage for application schema generation (function description, params/output). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+50
to
+51
| false, | ||
| params.additionalProperties, |
Comment on lines
+87
to
+88
| false, | ||
| func.output.additionalProperties, |
Comment on lines
+441
to
+449
| func llmSchemaProgrammer_clone(input map[string]any) map[string]any { | ||
| output := map[string]any{} | ||
| for key, value := range input { | ||
| if llmSchemaProgrammer_is_nil_like(value) { | ||
| continue | ||
| } | ||
| output[key] = value | ||
| } | ||
| return output |
Comment on lines
+581
to
+586
| func llmSchemaProgrammer_is_reference(schema map[string]any) bool { | ||
| _, ok := schema["$ref"].(string) | ||
| return ok | ||
| } | ||
|
|
||
| func llmSchemaProgrammer_is_null(schema map[string]any) bool { |
Comment on lines
+24
to
+25
| false, | ||
| params.additionalProperties, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant improvements and refactoring to the LLM parameters and application schema conversion logic in the Typia codebase. The changes primarily focus on unifying and simplifying how parameters and schemas are converted, ensuring stricter and more consistent schema outputs, and removing special-case handling for runtime imports. Additionally, comprehensive new test suites have been added to validate the correctness of the schema conversion logic for both parameters and application-level schemas.
Core logic improvements and refactoring:
llmApplicationProgrammer_convertParameters), ensuring consistent handling of config and schema details, and removed redundant or legacy functions. [1] [2] [3] [4] [5] [6]Runtime import and alias handling cleanup:
__typia_utilsalias in runtime import generation, alias collection, ranking, and module resolution, streamlining the logic for all runtime aliases. [1] [2] [3] [4]Test coverage enhancements:
test_llm_parameters_converter_matrix.ts), parameter property specifications (test_llm_parameters_spec_properties.ts), and application schema conversion (test_llm_application_schema_converter_matrix.ts), covering edge cases and ensuring strictness and correctness of the generated schemas. [1] [2] [3]These changes collectively improve the maintainability, correctness, and test coverage of the schema conversion logic in Typia, while removing unnecessary complexity and legacy code paths.