Skip to content

Conversation

@dineshreddy91
Copy link
Contributor

Summary

Simplifies and clarifies the base_url resolution logic across the codebase.

Changes

CLI (vlmrun/cli/cli.py)

  • Added resolve_base_url() and resolve_api_key() helper functions with clear priority:
    • arg > env var > config file > default
  • Removed redundant config lookups in check_credentials()
  • Simplified the default URL detection logic
  • Values are now resolved once in main() before passing to VLMRun()

Client (vlmrun/client/client.py)

  • Added _resolve_base_url() and _resolve_api_key() helper functions with clear priority:
    • arg > env var > default
  • URL is now normalized (trailing slash stripped) at resolution time
  • Simplified __post_init__() to just two lines
  • Better docstrings explaining priority order

APIRequestor (vlmrun/client/base_requestor.py)

  • Simplified URL building since base_url is now pre-normalized
  • Changed from urljoin() to simple f-string: f"{self._base_url}/{url.lstrip('/')}"
  • Removed unused urljoin import

Priority Order Summary

Source CLI Priority Client Priority
Argument 1st 1st
Env var (VLMRUN_BASE_URL) 2nd 2nd
Config file 3rd N/A
Default 4th 3rd

Testing

  • All CLI config tests pass
  • Import verification successful

- Add resolve_base_url/resolve_api_key helpers in CLI with priority: arg > env > config > default
- Add _resolve_base_url/_resolve_api_key helpers in client with priority: arg > env > default
- Normalize base_url (strip trailing slashes) at resolution time
- Simplify URL building in APIRequestor using f-string instead of urljoin
- Remove redundant config lookups in check_credentials()
- Update docstrings to document priority order

Bump version to 0.5.4
@gemini-code-assist
Copy link

Summary of Changes

Hello @dineshreddy91, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the API key and base URL resolution logic across the vlmrun codebase, aiming to enhance clarity, consistency, and maintainability. By introducing dedicated helper functions and a well-defined priority order for sourcing these critical configuration values, the changes simplify credential handling in both the command-line interface and the Python client, making the system more robust and easier to understand for developers.

Highlights

  • Centralized Configuration Resolution: Introduced dedicated helper functions (resolve_base_url, resolve_api_key in CLI and _resolve_base_url, _resolve_api_key in client) to centralize and standardize the resolution of API keys and base URLs.
  • Clear Priority Order: Established and documented a consistent priority order for configuration values: command-line argument > environment variable > config file (for CLI) > default value. The client follows argument > environment variable > default.
  • Simplified Credential Checks and Initialization: Streamlined the check_credentials function in the CLI and refactored the VLMRun client's __post_init__ method to leverage the new resolution helpers, significantly reducing their complexity and improving readability.
  • Improved URL Handling: Normalized base_url by stripping trailing slashes at the point of resolution, simplifying URL construction in APIRequestor by allowing direct f-string concatenation instead of urljoin.
  • Version Update: The package version has been incremented from 0.5.3 to 0.5.4.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dineshreddy91 dineshreddy91 requested review from shahrear33 and spillai and removed request for spillai January 27, 2026 01:23
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request does a great job of refactoring and simplifying the base_url and api_key resolution logic. By centralizing the resolution with clear priority in helper functions, the code is now more maintainable and easier to understand. The changes in the CLI and client modules are well-executed. I've found one minor issue regarding a type hint in vlmrun/cli/cli.py, which is a simple fix.

return get_config().api_key


def check_credentials(ctx: typer.Context, api_key: str, base_url: str) -> None:

Choose a reason for hiding this comment

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

medium

The type hint for api_key is str, but it can receive None. The resolve_api_key function returns Optional[str], and its result is passed here. The logic correctly handles the None case, but the type hint should be updated to Optional[str] to match the actual type and avoid potential issues with static analysis tools.

Suggested change
def check_credentials(ctx: typer.Context, api_key: str, base_url: str) -> None:
def check_credentials(ctx: typer.Context, api_key: Optional[str], base_url: str) -> None:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant