[BREAKING_CHANGES] ChatCompletionRequest in chat.go, chagne data type float32 to float64 #517
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.
Solve Issue: #9
Describe the change
ChatCompletionRequest struct attributes annotation with omitempty treats value 0 as not set, for example
temperature
,top_p
attribute. And this will trigger OpenAI use default value1
, temperature attribute specifically. OpenAI Chat Temperature DocData type
float32
is not competent for some DBs like MongoDB data type. The only two options to store float data in MongoDB areDouble
orDecimal128
, either way will arise error of "float64 can only be truncated to an integer type when truncation is enable" and "cannot decode 128-bit decimal into a float32 or float64 type" respectively in Golang float32.Describe your solution
omitempty
tag in ChatCompletionRequest.float32
tofloat64
.Tests
In MongoDB document, set attribute value data type as
Double
and temperature value to0
or0.01
, won't cause error.