sashabaranov / go-openai

OpenAI ChatGPT, GPT-3, GPT-4, DALL·E, Whisper API wrapper for Go
Apache License 2.0
9.25k stars 1.42k forks source link

fix: jsonschema integer validation #852

Closed WeiAnAn closed 1 month ago

WeiAnAn commented 2 months ago

Describe the change Fix the jsonschema validation failed failure on the integer field.

Provide OpenAI documentation link

Describe your solution Follow the #837 instruction. Because go unmarshalls all numbers as float64, we should check the value is an integer.

Tests Add jsonschema.Integer cases, include a success and a failed case.

Additional context Add any other context or screenshots or logs about your pull request here. If the pull request relates to an open issue, please link to it.

Issue: #837

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.01%. Comparing base (774fc9d) to head (7831bde). Report is 50 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #852 +/- ## ========================================== + Coverage 98.46% 99.01% +0.55% ========================================== Files 24 26 +2 Lines 1364 1422 +58 ========================================== + Hits 1343 1408 +65 + Misses 15 8 -7 Partials 6 6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sashabaranov commented 2 months ago

Thank you for the PR! Looks good, and here's a minimal example validating the float64 argument https://go.dev/play/p/VRMIyt9Zjqz