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

Add support for O3-mini #930

Conversation

rorymalcolm
Copy link
Contributor

- Add support for the o3 mini set of models, including tests that match the constraints in OpenAI's API docs (https://platform.openai.com/docs/models#o3-mini).
Copy link

codecov bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.87%. Comparing base (774fc9d) to head (0c88b1c).
Report is 82 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #930      +/-   ##
==========================================
+ Coverage   98.46%   98.87%   +0.41%     
==========================================
  Files          24       27       +3     
  Lines        1364     1779     +415     
==========================================
+ Hits         1343     1759     +416     
+ Misses         15       14       -1     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@1x-eng
Copy link

1x-eng commented Jan 31, 2025

yes please!

completion.go Outdated Show resolved Hide resolved
@rorymalcolm rorymalcolm force-pushed the rorymalcolm/add-support-for-o3-mini branch 5 times, most recently from 9978505 to 25581e5 Compare February 1, 2025 00:55
- Deprecate `ErrO1BetaLimitationsLogprobs` and `ErrO1BetaLimitationsOther`

- Implement `validationRequestForReasoningModels`, which works on both o1 & o3, and has per-model-type restrictions on functionality (eg, o3 class are allowed function calls and system messages, o1 isn't)
@rorymalcolm rorymalcolm force-pushed the rorymalcolm/add-support-for-o3-mini branch from 25581e5 to 1ad88a3 Compare February 1, 2025 00:59
@sash20m
Copy link

sash20m commented Feb 1, 2025

Thanks for that.

@rorymalcolm I observed the full O1 model hasn't been added in the lib. Can you add it as well along with O3 ? I would appreciate it a lot.
https://platform.openai.com/docs/models#o1
The o1-2024-12-17 model.

Thanks

chat_test.go Outdated
@@ -64,15 +64,15 @@ func TestO1ModelsChatCompletionsDeprecatedFields(t *testing.T) {
MaxTokens: 5,
Model: openai.O1Preview,
},
expectedError: openai.ErrO1MaxTokensDeprecated,
expectedError: openai.ErrO3MaxTokensDeprecated,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a bit weird — we're requesting an o1 model but are getting an o3 error instead. I suggest we name these errors more generic like use ReasoningModel instead of O3 — this would future-proof us for o4, o5, etc.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I know they're intending to merge the models in the near future, the normal and reasoning capabilities will be under the same model. Most likely we'll specify to use reasoning with an option param in the API.

Just fyi, if it changes anything about the implementation.

completion.go Outdated
var O3SeriesModels = map[string]struct{}{
O3Mini: {},
O3Mini20250131: {},
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to bookkeep this map forever and ever, could we use the strings.HasPrefix("o3-") instead?

completion.go Outdated
return nil
}

func validateBasicParams(request ChatCompletionRequest) error {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method name is pretty generic, let's make it's name clearly indicate that it is used only for reasoning models. Maybe even put all the logic related to reasoning models into a separate file (struct?)

@sashabaranov
Copy link
Owner

Thank you for the updates! I left a few minor comments, but it generally looks good 🙌🏻

Ah, we also miss a test case in chat_stream.go!

@rorymalcolm
Copy link
Contributor Author

Thank you for the updates! I left a few minor comments, but it generally looks good 🙌🏻

Ah, we also miss a test case in chat_stream.go!

Now done

@rorymalcolm rorymalcolm force-pushed the rorymalcolm/add-support-for-o3-mini branch 3 times, most recently from 7424d67 to ef7a4de Compare February 2, 2025 14:34
- Add a `NewReasoningValidator` which exposes a `Validate()` method for a given request

- Also adds a test for chat streams
@rorymalcolm rorymalcolm force-pushed the rorymalcolm/add-support-for-o3-mini branch from ef7a4de to e61a78d Compare February 2, 2025 14:36
@1x-eng
Copy link

1x-eng commented Feb 4, 2025

@sashabaranov is this merge ready? i need o3-mini sooner than later, switching to OAI's official go sdk is a pain id rather avoid. plmk if this can go in soon-ish? thanks

@rorymalcolm rorymalcolm force-pushed the rorymalcolm/add-support-for-o3-mini branch from 495c905 to 0c88b1c Compare February 5, 2025 22:51
Copy link
Owner

@sashabaranov sashabaranov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thank you!

@sashabaranov sashabaranov merged commit 2054db0 into sashabaranov:master Feb 6, 2025
3 checks passed
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.

4 participants