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

[Bug]: #17307 introduced errors for Azure OpenAI o1-based models #17544

Open
EmanueleMeazzo opened this issue Jan 17, 2025 · 2 comments
Open
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized

Comments

@EmanueleMeazzo
Copy link

Bug Description

#17307 introduced a regression for O1 models hosted in Azure OpenaAI

When using an O1 Azure OpenAI model the following error appears:

Error code: 400 - {'error': {'message': "Invalid value: 'developer'. Supported values are: 'system', 'assistant', 'user', 'function', and 'tool'.", 'type': 'invalid_request_error', 'param': 'messages[0].role', 'code': 'invalid_value'}}

That's because in #17307 it was introduced this code to change the role of the system prompt for OpenAI messages, but this doesn't work in Azure OpenAI as they still use the old format:

# TODO: O1 models do not support system prompts if model is not None and model in O1_MODELS: if message_dict["role"] == "system": message_dict["role"] = "developer"
Since AzureOpenAI imports from OpenAI

#base.py from llama_index.llms.openai import OpenAI

The same behaviour is wrongly applied to the AzureOpenAI class

Version

0.12.11

Steps to Reproduce

  • Instantiate a client using AzureOpenAI with an O1 model
  • Use anything that passes a system message to the llm
  • Error 400 {'error': {'message': "Invalid value: 'developer'. Supported values are: 'system', 'assistant', 'user', 'function', and 'tool'.", 'type': 'invalid_request_error', 'param': 'messages[0].role', 'code': 'invalid_value'}}

Relevant Logs/Tracbacks

@EmanueleMeazzo EmanueleMeazzo added bug Something isn't working triage Issue needs to be triaged/prioritized labels Jan 17, 2025
Copy link

dosubot bot commented Jan 17, 2025

@EmanueleMeazzo Hello! I'm here to help you with any bugs, questions, or contributions while you wait for a human maintainer.

The issue you're encountering is due to a change introduced in pull request #17307, which modifies the role of system prompts to "developer" for O1 models. This change is not compatible with Azure OpenAI, which still expects the old format with roles like "system", "assistant", "user", "function", and "tool" [1].

To resolve this, you would need to ensure that the role conversion logic does not apply to Azure OpenAI models or adjust the role conversion to match Azure's expected values. This might involve modifying the code to check if the model is an Azure OpenAI model and skip or adjust the role conversion accordingly.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@logan-markewich
Copy link
Collaborator

classic azure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Issue needs to be triaged/prioritized
Projects
None yet
Development

No branches or pull requests

2 participants