zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.45k stars 3.12k forks source link

Override OpenAI temperature #20805

Open Araz-g opened 4 days ago

Araz-g commented 4 days ago

Check for existing issues

Describe the feature

Support passing temperature to OpenAI models.

Environment

none

notpeter commented 3 days ago

There are a handful of POST request keys which are supported on certain OpenAI models via the v1/chat/completions endpoint:

parameter values default description
temperature 0.0-2.0 1.0 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.
top_p 0.0-1.0 1.0 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
presence_penalty -2.0 - 2.0 0 Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
metadata {} null Developer-defined tags and values used for filtering completions in the dashboard.
seed integer null The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. If a seed is not specified, one will be generated for you.

Source

Note, for some models, notably o1, it is invalid to provide these explicitly. As a result, and of the configurations should be done via the available_models objects and cannot be done at the provider level.

temperature and top_p are fixed at 1, while presence_penalty and frequency_penalty are fixed at 0.

I'm not sure whether it makes sense to specifically add support for just temperature, a subset or all of these. Maybe it would make sense to add support for an extra object which would be merged with the POST request object. Not sure.

KhazAkar commented 2 days ago

I'm personally in favor of adding such option to OpenAI, as well as for Ollama. It applies extra, when you use non-default openAI endpoint, like LocalAI, groq or cerebras