-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround openai issue with temperature: 0 being omitted from request
This PR adds a workaround for [this GitHub discussion][gh], describing how chat completion requests which explicitly set temperature = 0 are marshalled to JSON incorrectly (due to the 0 being indistinguishable from the zero value of the field). To do so we add a custom unmarshal method which checks whether the field was defined and set to zero, and explicitly set the temperature to `math.SmallestNonzeroFloat32` in such cases. This isn't perfect but is likely to get very similar results in practice. [gh]: sashabaranov/go-openai#9 (comment)
- Loading branch information
Showing
2 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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