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

Chore: Add openai o1 support #366

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

StrongMonkey
Copy link
Contributor

@StrongMonkey StrongMonkey commented Jan 23, 2025

Add openai o1 support in proxy to modify request body.

obot-platform/obot#1131

@@ -96,6 +101,41 @@ func (s *server) proxyDirector(req *http.Request) {
if s.cfg.PathPrefix != "" && !strings.HasPrefix(req.URL.Path, s.cfg.PathPrefix) {
req.URL.Path = s.cfg.PathPrefix + req.URL.Path
}

if req.Body == nil || req.Method != http.MethodPost {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to do this?

Suggested change
if req.Body == nil || req.Method != http.MethodPost {
if req.Body == nil || s.cfg.UpstreamHost != "api.openai.com" || req.URL.Path != "/v1/chat/completion" {

Copy link
Collaborator

@g-linville g-linville Jan 24, 2025

Choose a reason for hiding this comment

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

I like this, because it means that we can look for errors when we try to unmarshal the body later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, I will change this.

Signed-off-by: Daishan Peng <[email protected]>
Signed-off-by: Daishan Peng <[email protected]>
@StrongMonkey StrongMonkey force-pushed the openai-o1 branch 3 times, most recently from aa67dc3 to bd15449 Compare January 24, 2025 22:57
@StrongMonkey
Copy link
Contributor Author

@thedadams Pushed a change that make the response compatiable with stream client in gptscript.

return nil
}

func isModelO1(model string) bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current PR only supports o1, as o1-mini doesn't seem to support system message which could screw a lot of things. We could investigate in a different issue.

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.

3 participants