feat(openai): added support for o1 reasoning models #1618
Merged
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.
Summary
systemRoleSupported
for the OpenAI endpoint.max_completion_tokens
overmax_tokens
when queryingchat_completions
endpoint.The bugfix is necessary as
o1-preview
ando1-mini
models do not support "system" message types.The token configuration change was necessary as
o1-preview
ando1-mini
no longer support the, now deprecated,max_tokens
field.Considerations
I added a new endpoint configuration field called
useCompletionTokens
and defaulted it totrue
.This would have the effect of changing the default
chat_completions
call to usemax_completion_tokens
overmax_tokens
.There may be unintended consequences for users, as this could increase their overall token usage per query (as the default would change).
It may be prudent to start with this field set to
false
, and later switch totrue
as part of a planned deprecate ofmax_tokens
all together.Another consideration is that my change for system messages will leave a
"role": "user", "content": ""
entry. One thing we may want is to drop the system message entirely if content is blank and system messages are not supported.Reference
For those wanting to introduce o1 reasoning models based on this PR (future readers), here is an example implementation of
o1-mini
: