-
Notifications
You must be signed in to change notification settings - Fork 105
Add up-to-date Azure OpenAI Agents #284
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -262,6 +262,39 @@ | |
| chat_model_args=CHAT_MODEL_ARGS_DICT["openai/gpt-4o-mini-2024-07-18"], | ||
| flags=FLAGS_GPT_4o, | ||
| ) | ||
|
|
||
| AGENT_AZURE_4o_MINI = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-4o-mini-2024-07-18"], | ||
| flags=FLAGS_GPT_4o, | ||
| ) | ||
| AGENT_AZURE_4o = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-4o-2024-08-06"], | ||
| flags=FLAGS_GPT_4o, | ||
| ) | ||
| AGENT_AZURE_41 = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-4.1-2025-04-14"], | ||
| flags=FLAGS_GPT_4o, | ||
| ) | ||
| AGENT_AZURE_41_MINI = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-4.1-mini-2025-04-14"], | ||
| flags=FLAGS_GPT_4o, | ||
| ) | ||
|
|
||
| AGENT_AZURE_5 = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-5-2025-08-07"], | ||
| flags=FLAGS_GPT_4o, | ||
| ) | ||
|
Comment on lines
+283
to
+286
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mismatched Model Flags
Tell me moreWhat is the issue?Using GPT-4 flags (FLAGS_GPT_4o) for GPT-5 models may not be appropriate as GPT-5 could have different capabilities and requirements. Why this mattersMismatched flags could lead to suboptimal performance or errors if GPT-5 has different token limits, capabilities, or API requirements compared to GPT-4. Suggested change ∙ Feature PreviewCreate specific flags for GPT-5 models that account for their unique capabilities: FLAGS_GPT_5 = GenericPromptFlags(
# GPT-5 specific configurations
max_prompt_tokens=100_000, # Adjust based on actual GPT-5 limits
# ... other GPT-5 specific settings
)
AGENT_AZURE_5 = GenericAgentArgs(
chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-5-2025-08-07"],
flags=FLAGS_GPT_5,
)Provide feedback to improve future suggestions💬 Looking for more details? Reply to this comment to chat with Korbit. |
||
|
|
||
| AGENT_AZURE_5_MINI = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-5-mini-2025-08-07"], | ||
| flags=FLAGS_GPT_4o, | ||
| ) | ||
|
|
||
| AGENT_AZURE_5_NANO = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-5-nano-2025-08-07"], | ||
| flags=FLAGS_GPT_4o, | ||
| ) | ||
|
|
||
| AGENT_CLAUDE_SONNET_35 = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["openrouter/anthropic/claude-3.5-sonnet:beta"], | ||
| flags=FLAGS_GPT_4o, | ||
|
|
@@ -298,6 +331,41 @@ | |
| flags=FLAGS_GPT_4o_VISION, | ||
| ) | ||
|
|
||
| AGENT_AZURE_4o_VISION = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-4o-2024-08-06"], | ||
| flags=FLAGS_GPT_4o_VISION, | ||
| ) | ||
|
|
||
| AGENT_AZURE_4o_MINI_VISION = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-4o-mini-2024-07-18"], | ||
| flags=FLAGS_GPT_4o_VISION, | ||
| ) | ||
|
|
||
| AGENT_AZURE_41_VISION = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-4.1-2025-04-14"], | ||
| flags=FLAGS_GPT_4o_VISION, | ||
| ) | ||
|
|
||
| AGENT_AZURE_41_MINI_VISION = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-4.1-mini-2025-04-14"], | ||
| flags=FLAGS_GPT_4o_VISION, | ||
| ) | ||
|
|
||
| AGENT_AZURE_5_VISION = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-5-2025-08-07"], | ||
| flags=FLAGS_GPT_4o_VISION, | ||
| ) | ||
|
|
||
| AGENT_AZURE_5_MINI_VISION = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-5-mini-2025-08-07"], | ||
| flags=FLAGS_GPT_4o_VISION, | ||
| ) | ||
|
|
||
| AGENT_AZURE_5_NANO_VISION = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-5-nano-2025-08-07"], | ||
| flags=FLAGS_GPT_4o_VISION, | ||
| ) | ||
|
|
||
| AGENT_CLAUDE_SONNET_35_VISION = GenericAgentArgs( | ||
| chat_model_args=CHAT_MODEL_ARGS_DICT["openrouter/anthropic/claude-3.5-sonnet:beta"], | ||
| flags=FLAGS_GPT_4o_VISION, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| import anthropic | ||
| import openai | ||
| from huggingface_hub import InferenceClient | ||
| from openai import NOT_GIVEN, AzureOpenAI, OpenAI | ||
| from openai import NOT_GIVEN, OpenAI | ||
|
|
||
| import agentlab.llm.tracking as tracking | ||
| from agentlab.llm.base_api import AbstractChatModel, BaseModelArgs | ||
|
|
@@ -110,14 +110,11 @@ def make_model(self): | |
| class AzureModelArgs(BaseModelArgs): | ||
| """Serializable object for instantiating a generic chat model with an Azure model.""" | ||
|
|
||
| deployment_name: str = None | ||
|
|
||
| def make_model(self): | ||
| return AzureChatModel( | ||
| model_name=self.model_name, | ||
| temperature=self.temperature, | ||
| max_tokens=self.max_new_tokens, | ||
| deployment_name=self.deployment_name, | ||
| log_probs=self.log_probs, | ||
| ) | ||
|
|
||
|
|
@@ -398,30 +395,28 @@ def __init__( | |
| self, | ||
| model_name, | ||
| api_key=None, | ||
| deployment_name=None, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deployment_name is no longer needed?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we switched from using the Here's the migration guide from Azure: https://learn.microsoft.com/en-us/azure/ai-foundry/openai/api-version-lifecycle?tabs=key#code-changes |
||
| temperature=0.5, | ||
| max_tokens=100, | ||
| max_retry=4, | ||
| min_retry_wait_time=60, | ||
| log_probs=False, | ||
| ): | ||
| api_key = api_key or os.getenv("AZURE_OPENAI_API_KEY") | ||
| endpoint = os.getenv("AZURE_OPENAI_ENDPOINT") | ||
| assert endpoint, "AZURE_OPENAI_ENDPOINT has to be defined in the environment" | ||
|
|
||
| client_args = { | ||
| "azure_deployment": deployment_name, | ||
| "azure_endpoint": endpoint, | ||
| "api_version": "2024-02-01", | ||
| "base_url": endpoint, | ||
| "default_query": {"api-version": "preview"}, | ||
| } | ||
|
Comment on lines
407
to
410
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unexplained API Version Hardcoding
Tell me moreWhat is the issue?The API version 'preview' is hardcoded without explanation of why this specific version is used or what features it enables. Why this mattersFuture developers may hesitate to update the API version without understanding its implications, potentially missing out on important features or bug fixes. Suggested change ∙ Feature PreviewAdd a constant at the module level with a comment explaining the choice: # Latest stable version supporting vision features and updated token limits
AZURE_API_VERSION = "preview"
client_args = {
"base_url": endpoint,
"default_query": {"api-version": AZURE_API_VERSION},
}Provide feedback to improve future suggestions💬 Looking for more details? Reply to this comment to chat with Korbit.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. migration guide from Azure: https://learn.microsoft.com/en-us/azure/ai-foundry/openai/api-version-lifecycle?tabs=key#code-changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for sharing the migration guide. That explains the use of "preview" for API version. Since it's documented in official Azure guidance, I'll withdraw my suggestion about adding explanatory comments. |
||
| super().__init__( | ||
| model_name=model_name, | ||
| api_key=api_key, | ||
| api_key_env_var="AZURE_OPENAI_API_KEY", | ||
| temperature=temperature, | ||
| max_tokens=max_tokens, | ||
| max_retry=max_retry, | ||
| min_retry_wait_time=min_retry_wait_time, | ||
| client_class=AzureOpenAI, | ||
| client_class=OpenAI, | ||
| client_args=client_args, | ||
| pricing_func=tracking.get_pricing_openai, | ||
| log_probs=log_probs, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,19 +20,27 @@ | |
| ] | ||
|
|
||
| CHAT_MODEL_ARGS_DICT = { | ||
| "openai/gpt-5-2025-08-07": OpenAIModelArgs( | ||
| model_name="gpt-5-2025-08-07", | ||
| max_total_tokens=400_000, | ||
| max_input_tokens=256_000, | ||
| max_new_tokens=128_000, | ||
| temperature=1, # gpt-5 supports temperature of 1 only | ||
| vision_support=True, | ||
| ), | ||
| "openai/gpt-5-nano-2025-08-07": OpenAIModelArgs( | ||
| model_name="gpt-5-nano-2025-08-07", | ||
| max_total_tokens=128_000, | ||
| max_input_tokens=128_000, | ||
| max_new_tokens=16_384, | ||
| max_total_tokens=400_000, | ||
| max_input_tokens=256_000, | ||
| max_new_tokens=128_000, | ||
| temperature=1, # gpt-5 supports temperature of 1 only | ||
| vision_support=True, | ||
| ), | ||
| "openai/gpt-5-mini-2025-08-07": OpenAIModelArgs( | ||
| model_name="gpt-5-mini-2025-08-07", | ||
| max_total_tokens=128_000, | ||
| max_input_tokens=128_000, | ||
| max_new_tokens=16_384, | ||
| max_total_tokens=400_000, | ||
| max_input_tokens=256_000, | ||
| max_new_tokens=128_000, | ||
| temperature=1, # gpt-5 supports temperature of 1 only | ||
| vision_support=True, | ||
| ), | ||
|
|
@@ -111,51 +119,71 @@ | |
| max_new_tokens=64_000, | ||
| temperature=1e-1, | ||
| ), | ||
| "openai/gpt-5-nano-2025-08-07": OpenAIModelArgs( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why deleting those?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a duplicate entry. The same key is already populated above. |
||
| model_name="gpt-5-nano-2025-08-07", | ||
| max_total_tokens=400_000, | ||
| max_input_tokens=400_000 - 4_000, | ||
| max_new_tokens=4_000, | ||
| temperature=1, # temperature param not supported by gpt-5 | ||
| ), | ||
| "openai/gpt-5-mini-2025-08-07": OpenAIModelArgs( | ||
| model_name="gpt-5-mini-2025-08-07", | ||
| max_total_tokens=400_000, | ||
| max_input_tokens=400_000 - 4_000, | ||
| max_new_tokens=4_000, | ||
| temperature=1, # temperature param not supported by gpt-5 | ||
| ), | ||
| "azure/gpt-35-turbo/gpt-35-turbo": AzureModelArgs( | ||
| model_name="gpt-35-turbo", | ||
| deployment_name="gpt-35-turbo", | ||
| max_total_tokens=8_192, | ||
| max_input_tokens=7500, | ||
| max_new_tokens=500, | ||
| ), | ||
| "azure/gpt-4o-2024-05-13": AzureModelArgs( | ||
| model_name="gpt-4o", | ||
| deployment_name="gpt-4o-2024-05-13", | ||
| max_total_tokens=128_000, | ||
| max_input_tokens=100_000, | ||
| max_new_tokens=16_384, | ||
| vision_support=True, | ||
| ), | ||
| "azure/gpt-4o-2024-08-06": AzureModelArgs( | ||
| model_name="gpt-4o", | ||
| deployment_name="gpt-4o-2024-08-06", | ||
| max_total_tokens=128_000, | ||
| max_input_tokens=128_000, | ||
| max_new_tokens=16_384, | ||
| vision_support=True, | ||
| ), | ||
| "azure/gpt-4o-mini-2024-07-18": AzureModelArgs( | ||
| model_name="gpt-4o-mini", | ||
| deployment_name="gpt-4o-mini-2024-07-18", | ||
| max_total_tokens=128_000, | ||
| max_input_tokens=128_000, | ||
| max_new_tokens=16_384, | ||
| vision_support=True, | ||
| ), | ||
| "azure/gpt-4.1-2025-04-14": AzureModelArgs( | ||
| model_name="gpt-4.1", | ||
| max_total_tokens=128_000, | ||
| max_input_tokens=128_000, | ||
| max_new_tokens=16_384, | ||
| vision_support=True, | ||
| ), | ||
| "azure/gpt-4.1-mini-2025-04-14": AzureModelArgs( | ||
| model_name="gpt-4.1-mini", | ||
| max_total_tokens=128_000, | ||
| max_input_tokens=128_000, | ||
| max_new_tokens=16_384, | ||
| vision_support=True, | ||
| ), | ||
| "azure/gpt-5-2025-08-07": AzureModelArgs( | ||
| model_name="gpt-5", | ||
| max_total_tokens=400_000, | ||
| max_input_tokens=256_000, | ||
| max_new_tokens=128_000, | ||
| temperature=1, # temperature param not supported by gpt-5 | ||
| vision_support=True, | ||
| ), | ||
| "azure/gpt-5-mini-2025-08-07": AzureModelArgs( | ||
| model_name="gpt-5-mini", | ||
| max_total_tokens=400_000, | ||
| max_input_tokens=256_000, | ||
| max_new_tokens=128_000, | ||
| temperature=1, # temperature param not supported by gpt-5 | ||
| vision_support=True, | ||
| ), | ||
| "azure/gpt-5-nano-2025-08-07": AzureModelArgs( | ||
| model_name="gpt-5-nano", | ||
| max_total_tokens=400_000, | ||
| max_input_tokens=256_000, | ||
| max_new_tokens=128_000, | ||
| temperature=1, # temperature param not supported by gpt-5 | ||
| vision_support=True, | ||
| ), | ||
| # ---------------- Anthropic ----------------# | ||
| "anthropic/claude-3-7-sonnet-20250219": AnthropicModelArgs( | ||
| model_name="claude-3-7-sonnet-20250219", | ||
|
|
||
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.
Invalid Future Model Versions
Tell me more
What is the issue?
The Azure agents are created using future dates (2024-2025) in their model versions, which are not yet available and would cause runtime errors when attempting to use these models.
Why this matters
Using non-existent model versions will cause the application to fail when trying to make API calls to Azure OpenAI services.
Suggested change ∙ Feature Preview
Update the model versions to use currently available Azure OpenAI models. For example:
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.