Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/agentlab/agents/generic_agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@
AGENT_4o_MINI,
AGENT_4o_MINI_VISION,
AGENT_4o_VISION,
AGENT_AZURE_4o_MINI,
AGENT_AZURE_4o,
AGENT_AZURE_4o_VISION,
AGENT_AZURE_4o_MINI_VISION,
AGENT_AZURE_41,
AGENT_AZURE_41_MINI,
AGENT_AZURE_41_VISION,
AGENT_AZURE_41_MINI_VISION,
AGENT_AZURE_5,
AGENT_AZURE_5_MINI,
AGENT_AZURE_5_NANO,
AGENT_AZURE_5_VISION,
AGENT_AZURE_5_MINI_VISION,
AGENT_AZURE_5_NANO_VISION,
AGENT_o1_MINI,
AGENT_o3_MINI,
FLAGS_GPT_4o,
Expand All @@ -46,6 +60,20 @@
"AGENT_37_SONNET",
"AGENT_4o_VISION",
"AGENT_4o_MINI_VISION",
"AGENT_AZURE_4o_MINI",
"AGENT_AZURE_4o",
"AGENT_AZURE_4o_VISION",
"AGENT_AZURE_4o_MINI_VISION",
"AGENT_AZURE_41",
"AGENT_AZURE_41_MINI",
"AGENT_AZURE_41_VISION",
"AGENT_AZURE_41_MINI_VISION",
"AGENT_AZURE_5",
"AGENT_AZURE_5_MINI",
"AGENT_AZURE_5_NANO",
"AGENT_AZURE_5_VISION",
"AGENT_AZURE_5_MINI_VISION",
"AGENT_AZURE_5_NANO_VISION",
"AGENT_CLAUDE_SONNET_35_VISION",
"AGENT_GPT5_MINI",
]
68 changes: 68 additions & 0 deletions src/agentlab/agents/generic_agent/agent_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Comment on lines +266 to +269
Copy link

Choose a reason for hiding this comment

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

Invalid Future Model Versions category Functionality

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:

AGENT_AZURE_4o_MINI = GenericAgentArgs(
    chat_model_args=CHAT_MODEL_ARGS_DICT["azure/gpt-4-1106-preview"],
    flags=FLAGS_GPT_4o,
)
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

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
Copy link

Choose a reason for hiding this comment

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

Mismatched Model Flags category Functionality

Tell me more
What 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 matters

Mismatched 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 Preview

Create 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

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 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,
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 5 additions & 10 deletions src/agentlab/llm/chat_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)

Expand Down Expand Up @@ -398,30 +395,28 @@ def __init__(
self,
model_name,
api_key=None,
deployment_name=None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

deployment_name is no longer needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, we switched from using the AzureOpenAI client to OpenAI as it allows us to remove one of the necessary env variables.

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
Copy link

Choose a reason for hiding this comment

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

Unexplained API Version Hardcoding category Readability

Tell me more
What 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 matters

Future developers may hesitate to update the API version without understanding its implications, potentially missing out on important features or bug fixes.

Suggested change ∙ Feature Preview

Add 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

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

The 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,
Expand Down
76 changes: 52 additions & 24 deletions src/agentlab/llm/llm_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down Expand Up @@ -111,51 +119,71 @@
max_new_tokens=64_000,
temperature=1e-1,
),
"openai/gpt-5-nano-2025-08-07": OpenAIModelArgs(
Copy link
Collaborator

Choose a reason for hiding this comment

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

why deleting those?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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",
Expand Down
Loading