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

Adds Supports for OpenAI Reasoning Models #3530

Open
wants to merge 4 commits into
base: 0.2
Choose a base branch
from
Open

Adds Supports for OpenAI Reasoning Models #3530

wants to merge 4 commits into from

Conversation

gagb
Copy link
Collaborator

@gagb gagb commented Sep 14, 2024

This pull request introduces support for a new set of models (o1 and o1-mini) in the OpenAI client.

Task List

  • Create new api_type
  • Add costs/token limits
  • Support max_completion_tokens
  • Display warning for multi-model messages?

New Client Support:

  • autogen/oai/client.py: Added a new class OpenAI_O1 to handle the o1 models, including a method to modify the role of messages before processing. Updated the client registration logic to include the new OpenAI_O1 client. [1] [2]

Model Configuration:

Testing:

  • test/twoagent-o1.py: Added a new sample file to show the integration of o1 models using AssistantAgent and UserProxyAgent.

Related: #3523

PS: I am going out for the evening; the new models feel slower for sure but return more detail responses. I bet the "system" prompts will need some tuning even though they aren't supported!

@gagb gagb requested a review from ekzhu September 14, 2024 03:18
@gagb gagb requested a review from afourney September 14, 2024 03:18
@gagb gagb changed the title Adds O1 example Adds Supports for OpenAI Reasoning Models Sep 14, 2024
@gagb gagb added the llm label Sep 14, 2024
@marklysze
Copy link
Collaborator

marklysze commented Sep 14, 2024

Would love to test but don't have tier 5 API access :) can look through code.

Note the current Beta Limitations:

  • Modalities: text only, images are not supported.
  • Message types: user and assistant messages only, system messages are not supported. [DONE]
  • Streaming: not supported.
  • Tools: tools, function calling, and response format parameters are not supported.

A few questions:

  • I can see that it's easier to handle the beta limitations through a new class/api_type, OpenAI_O1, though do you think these models will always warrant a different one?
  • Do you want to strip out streaming from params?
  • If max_tokens is in the params, it could be changed to max_completion_tokens (it looks like this is a common change to the OpenAI API, so would apply to all models)
  • Should system messages be updated with assistant or user? I thought the user may be more appropriate as an instruction to the model?

Copy link
Member

@afourney afourney left a comment

Choose a reason for hiding this comment

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

Great. Looks clean and simple.

@gagb
Copy link
Collaborator Author

gagb commented Sep 15, 2024

Would love to test but don't have tier 5 API access :) can look through code.

That's okay I really appreciate the feedback on the code :)

Note the current Beta Limitations:

  • Modalities: text only, images are not supported.
  • Message types: user and assistant messages only, system messages are not supported. [DONE]
  • Streaming: not supported.
  • Tools: tools, function calling, and response format parameters are not supported.

A few questions:

  • I can see that it's easier to handle the beta limitations through a new class/api_type, OpenAI_O1, though do you think these models will always warrant a different one?

Good question. Hard to know what they will do. But I am open to different solutions. The reason I like this is because it modular and backwards compatible. If they make further upgrades, we can depreciate this client?

  • Do you want to strip out streaming from params?
  • If max_tokens is in the params, it could be changed to max_completion_tokens (it looks like this is a common change to the OpenAI API, so would apply to all models)

Good point, I was trying to first get the basic version working. Will add this.

  • Should system messages be updated with assistant or user? I thought the user may be more appropriate as an instruction to the model?

You are correct. This was a typo.

@marklysze
Copy link
Collaborator

  • I can see that it's easier to handle the beta limitations through a new class/api_type, OpenAI_O1, though do you think these models will always warrant a different one?

Good question. Hard to know what they will do. But I am open to different solutions. The reason I like this is because it modular and backwards compatible. If they make further upgrades, we can depreciate this client?

I think that works :)

  • If max_tokens is in the params, it could be changed to max_completion_tokens (it looks like this is a common change to the OpenAI API, so would apply to all models)

Good point, I was trying to first get the basic version working. Will add this.

Thanks!

  • Should system messages be updated with assistant or user? I thought the user may be more appropriate as an instruction to the model?

You are correct. This was a typo.

Nice, all good :)

Copy link
Collaborator

@LittleLittleCloud LittleLittleCloud left a comment

Choose a reason for hiding this comment

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

LGTM, left with a small question

super().__init__(OpenAI(**kwargs))

def create(self, params: Dict[str, Any]) -> ChatCompletion:
print(params["messages"])

Choose a reason for hiding this comment

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

is the print statement required here ?

@rysweet
Copy link
Collaborator

rysweet commented Oct 11, 2024

looks like some open questions still... @gagb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.2 Issues which are related to the pre 0.4 codebase awaiting-op-response Issue or pr has been triaged or responded to and is now awaiting a reply from the original poster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants