Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/agentlab/llm/chat_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def __init__(
min_retry_wait_time=min_retry_wait_time,
api_key_env_var="VLLM_API_KEY",
client_class=OpenAI,
client_args={"base_url": "http://0.0.0.0:8000/v1"},
client_args={"base_url": os.getenv("VLLM_API_URL", "http://localhost:8000/v1")},
Copy link

Choose a reason for hiding this comment

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

Repeated environment variable lookup on model instantiation category Performance

Tell me more
What is the issue?

The os.getenv() call is executed on every VLLMChatModel instantiation, performing an unnecessary environment variable lookup each time.

Why this matters

This creates redundant system calls when multiple VLLMChatModel instances are created, as the environment variable is unlikely to change during program execution. The overhead becomes more significant in scenarios with frequent model instantiation.

Suggested change ∙ Feature Preview

Cache the environment variable lookup at module level or class level to avoid repeated os.getenv() calls:

# At module level
VLLM_BASE_URL = os.getenv("VLLM_API_URL", "http://localhost:8000/v1")

# Then in __init__:
client_args={"base_url": VLLM_BASE_URL}
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.

pricing_func=None,
)

Expand Down
Loading