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

remove omitempty tag from temperature fields (#333) #334

Conversation

vvatanabe
Copy link
Collaborator

@vvatanabe vvatanabe commented May 31, 2023

I confirmed the OpenAI API documentation. The default value for temperature is 1. The temperature field of the request structure was given an omitempty tag, so a value of 0 was removed from the request parameter. It would be better to remove the omitempty tag so that 0 can be used.

Oops, removing the omitempty tag changes the default value in this client library.
I thought it would be better to change the temperature type to pointer(*float32). But that is BREAKING CHANGES.

Refs:

Note: For audio api only, the default value for temperature is 0.
Refs: https://platform.openai.com/docs/api-reference/audio/create

@vvatanabe vvatanabe changed the title [WIP] remove omitempty tag from temperature fields (#333) remove omitempty tag from temperature fields (#333) May 31, 2023
@vvatanabe vvatanabe changed the title remove omitempty tag from temperature fields (#333) [WIP] remove omitempty tag from temperature fields (#333) May 31, 2023
@codecov
Copy link

codecov bot commented May 31, 2023

Codecov Report

Merging #334 (7977a70) into master (61ba5f3) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #334   +/-   ##
=======================================
  Coverage   92.45%   92.45%           
=======================================
  Files          18       18           
  Lines         636      636           
=======================================
  Hits          588      588           
  Misses         35       35           
  Partials       13       13           
Impacted Files Coverage Δ
chat.go 100.00% <ø> (ø)
completion.go 100.00% <ø> (ø)
edits.go 100.00% <ø> (ø)

@vvatanabe vvatanabe changed the title [WIP] remove omitempty tag from temperature fields (#333) remove omitempty tag from temperature fields (#333) May 31, 2023
@vvatanabe
Copy link
Collaborator Author

Oops, removing the omitempty tag changes the default value in this client library.

I thought it would be better to change the temperature type to pointer(*float32). But that is BREAKING CHANGES.

@vvatanabe
Copy link
Collaborator Author

Wait for a major version upgrade.

@vvatanabe vvatanabe closed this Jun 1, 2023
@sashabaranov
Copy link
Owner

sashabaranov commented Jun 1, 2023

Hey, thank you for the PR, that's the oldest open issue we have in this repo #9

So the current behavior is that if you want to default to OpenAI's temperature default, you don't include the temperature parameter in the request. However, you can't set the temperature to exactly zero, only to some small non-zero float value.

I'm not sure there's a strong argument to break the current behavior, given that there are a lot of users relying on the current implementation.

@sashabaranov
Copy link
Owner

@vvatanabe I like the v2 idea, I guess we should discuss on what highest ROI breakages might be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants