Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ChatGPT strict mode configurable. #112

Merged
merged 1 commit into from
Dec 14, 2024
Merged

Make ChatGPT strict mode configurable. #112

merged 1 commit into from
Dec 14, 2024

Conversation

samchon
Copy link
Owner

@samchon samchon commented Dec 14, 2024

As I've understood that ChatGPT's strict mode is not perfect, and found much better way by giving validation feedback with typia.validate<T>() function, I've changed the ChatGPT strict mode to be configurable, and also changed ChatGPT function calling (or structured output) composition strategy.

From now on, ChatGPT schema also supports the optional properties and dynamic key typed object unless the strict mode configured.

Advised by @AcrylicShrimp


This pull request introduces a new strict mode configuration to the ChatGPT schema composer and updates various components to support this feature. The strict mode enforces stricter validation rules, such as requiring all object properties to be mandatory and disallowing additional properties.

Key changes include:

New Features:

  • Added a strict configuration option to IChatGptSchema.IConfig to enforce stricter validation rules.
  • Updated ChatGptSchemaComposer to use the new strict configuration for validation and transformation. [1] [2] [3] [4]

Validation Enhancements:

  • Introduced validateStrict function to enforce strict mode validation rules, ensuring no optional properties and no additional properties are allowed.
  • Modified IChatGptSchema.IParameters and related interfaces to reflect the new strict mode constraints. [1] [2] [3]

Schema Updates:

  • Updated LlmSchemaV3_1Composer and ChatGptSchemaComposer to handle additionalProperties correctly under strict mode. [1] [2] [3] [4] [5] [6] [7] [8]

Testing:

  • Added new test cases to verify the behavior of the strict mode in test_chatgpt_function_calling_additionalProperties, test_chatgpt_function_calling_optional, and test_chatgpt_schema_additionalProperties. [1] [2] [3]

Miscellaneous:

  • Bumped the version of the @samchon/openapi package to 2.2.0.

These changes collectively enhance the robustness and flexibility of the schema validation process, especially for use cases requiring strict adherence to predefined schemas.

As I've understood that ChatGPT's strict mode is not perfect, and found much better way by giving validation feedback with `typia.validate<T>()` function, I've changed the ChatGPT strict mode to be configurable, and also changed ChatGPT function calling (or structured output) composition strategy.

From now on, ChatGPT schema also supports the optional properties and dynamic key typed object unless the strict mode configured.
@samchon samchon added documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers labels Dec 14, 2024
@samchon samchon self-assigned this Dec 14, 2024
Copy link
Owner Author

@samchon samchon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test OK

@samchon samchon merged commit 6f0f412 into master Dec 14, 2024
4 checks passed
@samchon samchon deleted the feat/optional branch December 14, 2024 21:57
samchon added a commit to samchon/typia that referenced this pull request Dec 14, 2024
samchon added a commit to samchon/typia that referenced this pull request Dec 14, 2024
Adapt samchon/openapi#112: ChatGPT strict mode configurable.
Yradex pushed a commit to Yradex/lynx-stack that referenced this pull request Mar 4, 2025
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [typia](https://typia.io)
([source](https://redirect.github.com/samchon/typia)) | [`7.0.2` ->
`7.5.1`](https://renovatebot.com/diffs/npm/typia/7.0.2/7.5.1) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/typia/7.5.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/typia/7.5.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/typia/7.0.2/7.5.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/typia/7.0.2/7.5.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>samchon/typia (typia)</summary>

###
[`v7.5.1`](https://redirect.github.com/samchon/typia/releases/tag/v7.5.1)

[Compare
Source](https://redirect.github.com/samchon/typia/compare/v7.5.0...v7.5.1)

#### What's Changed

- Update typedoc requirement from ^0.27.4 to ^0.27.5 in /website in the
ecosystem group by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/samchon/typia/pull/1437](https://redirect.github.com/samchon/typia/pull/1437)
- Fix `ILlmFunction.parameters.description` problem. by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1442](https://redirect.github.com/samchon/typia/pull/1442)

**Full Changelog**:
samchon/typia@v7.5.0...v7.5.1

###
[`v7.5.0`](https://redirect.github.com/samchon/typia/releases/tag/v7.5.0)

[Compare
Source](https://redirect.github.com/samchon/typia/compare/v7.4.2...v7.5.0)

Special update for commercial project performing LLM function calling to
the Rest API.

#### What's Changed

- Adapt `@samchon/[email protected]`. by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1440](https://redirect.github.com/samchon/typia/pull/1440)

**Full Changelog**:
samchon/typia@v7.4.2...v7.5.0

###
[`v7.4.2`](https://redirect.github.com/samchon/typia/releases/tag/v7.4.2)

[Compare
Source](https://redirect.github.com/samchon/typia/compare/v7.4.1...v7.4.2)

#### What's Changed

- Fix `typia.llm.applicationOfValidate()` function in generation mode.
by [@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1439](https://redirect.github.com/samchon/typia/pull/1439)

**Full Changelog**:
samchon/typia@v7.4.1...v7.4.2

###
[`v7.4.1`](https://redirect.github.com/samchon/typia/releases/tag/v7.4.1)

[Compare
Source](https://redirect.github.com/samchon/typia/compare/v7.4.0...v7.4.1)

#### What's Changed

- Fix LLM schema recursive type detector. by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1438](https://redirect.github.com/samchon/typia/pull/1438)

**Full Changelog**:
samchon/typia@v7.4.0...v7.4.1

###
[`v7.4.0`](https://redirect.github.com/samchon/typia/releases/tag/v7.4.0)

[Compare
Source](https://redirect.github.com/samchon/typia/compare/v7.3.0...v7.4.0)

#### What's Changed

- feat(ci): update node versions by
[@&#8203;ryoppippi](https://redirect.github.com/ryoppippi) in
[https://github.com/samchon/typia/pull/1414](https://redirect.github.com/samchon/typia/pull/1414)
- Adapt
[samchon/openapi#112](https://redirect.github.com/samchon/openapi/issues/112):
ChatGPT strict mode configurable. by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1434](https://redirect.github.com/samchon/typia/pull/1434)

**Full Changelog**:
samchon/typia@v7.3.0...v7.4.0

###
[`v7.3.0`](https://redirect.github.com/samchon/typia/releases/tag/v7.3.0)

[Compare
Source](https://redirect.github.com/samchon/typia/compare/88ca453c1cad0fc5acd465e66380007331b360e8...v7.3.0)

#### What's Changed

- Adapt nextra v3 update by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1422](https://redirect.github.com/samchon/typia/pull/1422)
- Refactor README and index.html by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1423](https://redirect.github.com/samchon/typia/pull/1423)
- Fixing
[#&#8203;1227](https://redirect.github.com/samchon/typia/issues/1227):
documentation of `UniqueItems` by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1424](https://redirect.github.com/samchon/typia/pull/1424)
- Block LLM function schema composition by `@human` tag. by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1427](https://redirect.github.com/samchon/typia/pull/1427)
- `ILlmFunction.strict` has been removed. by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1428](https://redirect.github.com/samchon/typia/pull/1428)

**Full Changelog**:
samchon/typia@v7.2.0...v7.3.0

###
[`v7.2.1`](https://redirect.github.com/samchon/typia/compare/v7.2.0...88ca453c1cad0fc5acd465e66380007331b360e8)

[Compare
Source](https://redirect.github.com/samchon/typia/compare/v7.2.0...88ca453c1cad0fc5acd465e66380007331b360e8)

###
[`v7.2.0`](https://redirect.github.com/samchon/typia/releases/tag/v7.2.0)

[Compare
Source](https://redirect.github.com/samchon/typia/compare/v7.1.0...v7.2.0)

#### What's Changed

- Report `TransformError` in website playground. by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1420](https://redirect.github.com/samchon/typia/pull/1420)
- Update typedoc requirement from ^0.27.3 to ^0.27.4 in /website in the
ecosystem group by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/samchon/typia/pull/1419](https://redirect.github.com/samchon/typia/pull/1419)
- Add `IValidation.IError.data` property. by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1421](https://redirect.github.com/samchon/typia/pull/1421)

**Full Changelog**:
samchon/typia@v7.1.0...v7.2.0

###
[`v7.1.0`](https://redirect.github.com/samchon/typia/releases/tag/v7.1.0)

[Compare
Source](https://redirect.github.com/samchon/typia/compare/v7.0.2...v7.1.0)

#### What's Changed

- Bump typedoc from 0.26.11 to 0.27.3 in /website in the ecosystem group
across 1 directory by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/samchon/typia/pull/1416](https://redirect.github.com/samchon/typia/pull/1416)
- New function `typia.llm.applicationOfValidate()`. by
[@&#8203;samchon](https://redirect.github.com/samchon) in
[https://github.com/samchon/typia/pull/1418](https://redirect.github.com/samchon/typia/pull/1418)

**Full Changelog**:
samchon/typia@v7.0.2...v7.1.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/lynx-wg/lynx-stack).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS44MC4wIiwidXBkYXRlZEluVmVyIjoiMzkuODAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsicmVub3ZhdGUiXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Qingyu Wang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers
Projects
No open projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant