-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Python: Feat/Add DEVELOPER role for openai o1 #10033
base: main
Are you sure you want to change the base?
Python: Feat/Add DEVELOPER role for openai o1 #10033
Conversation
…de of _inner_get_streaming_chat_message_contents has been removed.
…atCompletionBase.
Thanks for having a look at this, @ymuichiro. I think it’d be good to make sure other o1 api features are in as well. I saw they have a reasoning_effort param, too. Are there other features we’d want to get in to make sure the o1 experience works well? |
Thank you for checking this so quickly. Regarding o1, here are the changes I’m aware of: ※ It might be worth considering providing o1: 2024-12-17
{
"completion_tokens": 1843,
"prompt_tokens": 20,
"total_tokens": 1863,
"completion_tokens_details": {
"audio_tokens": null,
"reasoning_tokens": 448
},
"prompt_tokens_details": {
"audio_tokens": null,
"cached_tokens": 0
}
} Currently Unsupported • Parallel tool invocation It would be nice if these were applied to settings, usage, and author_role. |
I agree @moonbox3 bit more work is needed to make sure we fully support o1, these extra settings can just be added with None defaults, but we also need to consider the rendered prompt to ChatHistory parser, that uses a system message as default, that can be left as is, but might throw when used with o1 but might also be usefull to have a look at how we can support this as well! |
Thank you for your comment. After reviewing the current Semantic Kernel code, I found several instances where With that in mind, I am planning to proceed with the following tasks. Does this approach make sense to you?
※ Most methods can be reused, so it might be sufficient to simply override some methods of the existing
Regarding item 2, even if certain properties cannot be used, I believe it is the responsibility of the user to ensure only valid properties are passed. Therefore, I plan to set the default values for these properties to Furthermore, regarding the new response property |
Hi @ymuichiro thanks for the follow up details. Just getting back to the office after holidays - apologies for the slow reply. As I have a lot of items to go through, let me dig deeper into this today, and I can provide some more comments. As per @eavanvalkenburg's comment above, we do need to think about how the chat history will be handled now that o1 doesn't support the system message -- today one can specify the system message via the constructor, so we'd need to now handle this in a different way. Another quick thought is: could we have Let me circle back soon. And thank you again for all your work on this thus far. |
I'm not sure if a seperate PES makes things easier or harder, not having too many settings is great, but we rely on the class property for the "right" PES at different points and having two possibly valid PES's means headaches for that, we could say, check the model id, if starts with |
@ymuichiro thanks for your patience, me and @moonbox3 had a chat on this, the current PR is good, and please also add the two new params (max_completion_tokens and reasoning_effort) to the existing OpenAIChatPromptExecutionSettings, we will need to have a broader discussion in our team on how to handle this more broadly so for now we will just add without breaking anyone! Thanks again! |
…reasoning_effort) for OpenAI
0c5fdb0
to
afb791d
Compare
Thank you very much for your review. I have just added a commit with additional modifications. |
Don't worry about your commits, the pr gets squashed on merge anyway |
Was just going to write this -- you beat me to it! |
Python Test Coverage Report •
Python Unit Test Overview
|
Thanks for your help on this, @ymuichiro. |
@@ -96,6 +96,19 @@ class OpenAIChatPromptExecutionSettings(OpenAIPromptExecutionSettings): | |||
dict[str, Any] | None, | |||
Field(description="Additional options to pass when streaming is used. Do not set this manually."), | |||
] = None | |||
max_completion_tokens: Annotated[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only other suggestion for this (along with fixing the unit tests), is that we should add a concept sample to show how to leverage the o1 model -- and make lots of comments around what is/ what is not supported:
- developer message instead of system
- parallel tool calls not yet supported (should set PES
parallel_tool_calls = False
- unsupported API parameters: temperature, top_p, presence_penalty, frequency_penalty, logprobs, top_logprobs, logit_bias
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I will add a note in the comments indicating that this is a property specific to o1. Additionally, I will include examples of how to use o1 in directories like /python/samples/concepts/reasoning/**.
To resolve the test error, I investigated the cause and found a challenging issue, so I am documenting it for now. The error occurs in the Azure AI Inference section. The test verifies whether all defined roles can be parsed by the Message class of Azure AI Inference. semantic-kernel/python/semantic_kernel/connectors/ai/azure_ai_inference/services/utils.py Line 138 in 2a5e51b
To pass the test, we would need to link the AuthorRole defined on the Semantic Kernel side with the ChatRole defined in the Azure AI Inference SDK. However, the Azure AI Inference SDK does not yet include the DEVELOPER role... As a temporary measure, we could prepare a placeholder function with a TODO: note or similar. However, this approach risks missing future updates, so I have started considering how best to address this issue |
@ymuichiro we had a chat on this one, we think it's best if the other classes raise an error for now when presented with a DEVELOPER message, that way we don't have to introduce behavior changes later on (the alternative is to map from developer to system, but then in the future if Azure AI Inference does support Developer it will change the behavior) |
Motivation and Context
Currently, the OpenAI O1 model introduces a new role "developer". However, passing the conventional "system" role results in an error. To address this issue, the following changes are proposed.
Description
Add a Method to the
ChatHistory
ClassExpand the
AuthorRole
Enum"developer"
as a new value to theAuthorRole
enum.Improve Developer Experience (UX)
"system"
role is mistakenly passed, the logic should internally convert it to"developer"
for better UX."system"
, simply adding support for the"developer"
role seems to be the most optimal solution at this point.Background
"system"
role, causing errors when it is passed."developer"
role must be integrated in a way that preserves compatibility with other models.Usage
Contribution Checklist