Skip to content

Conversation

@MehediAhamed
Copy link
Contributor

Issue:
The CLI passes session_id to client.agent.completions.create(), but the OpenAI Python client doesn't accept session_id (it's a VLM Run–specific parameter).

Changes:
In _cli/chat.py, fixing to send session_id via extra_body when present. Adding a helper to pass session_id via extra_body. The OpenAI client accepts extra_body and merges it into the request body, so the VLM Run backend still receives session_id.

Before
image

After
image
image

…ity issue as it used OpenAI client which did not support session id
@gemini-code-assist
Copy link

Summary of Changes

Hello @MehediAhamed, 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 addresses a critical compatibility problem within the VLM Run CLI where a VLM Run-specific parameter, session_id, was not correctly transmitted to the backend due to limitations in the underlying OpenAI Python client. The changes ensure that session_id is now properly included in API requests by leveraging the extra_body mechanism. Furthermore, the CLI's chat functionality has been enhanced to correctly default to the Agent API's base URL, improving the robustness and clarity of API endpoint configuration for chat operations.

Highlights

  • Session ID Compatibility: Resolved an issue where the VLM Run CLI's session_id parameter was incompatible with the OpenAI Python client's client.agent.completions.create() method, which did not natively support this VLM Run-specific argument.
  • Extra Body Utilization: Implemented a solution to pass the session_id through the OpenAI client's extra_body argument. This allows the VLM Run backend to receive the session_id correctly without requiring modifications to the OpenAI client itself.
  • Helper Function Introduction: A new helper function, _completion_create_kwargs, was introduced in vlmrun/cli/_cli/chat.py. This function centralizes the logic for building arguments for client.agent.completions.create(), including the extra_body handling for session_id.
  • Agent API Base URL Configuration: The CLI now automatically uses a dedicated DEFAULT_AGENT_BASE_URL for the chat subcommand when no specific base URL is explicitly provided. This ensures that chat-related API calls are correctly routed to the Agent API endpoint.

🧠 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.

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 correctly addresses the compatibility issue with the OpenAI client by passing the session_id through extra_body. The introduction of the _completion_create_kwargs helper function is a good refactoring that improves code clarity. The changes to support a separate default URL for the agent API are also appropriate. I've included one high-severity comment to address a bug in vlmrun/cli/cli.py where configuration from the config file is not being correctly applied, which could lead to incorrect behavior for users relying on configured settings.

Comment on lines +122 to +126
# Chat subcommand uses the Agent API; use agent base URL when none set
client_base_url = base_url
if ctx.invoked_subcommand == "chat" and client_base_url is None:
client_base_url = DEFAULT_AGENT_BASE_URL
ctx.obj = VLMRun(api_key=api_key, base_url=client_base_url)

Choose a reason for hiding this comment

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

high

The current logic for determining client_base_url doesn't account for the base_url that might be set in the user's config file. The base_url variable from typer.Option will be None if not provided via the CLI or an environment variable. This causes the logic to fall back to DEFAULT_AGENT_BASE_URL for the chat command, even if a custom URL is specified in the configuration file.

This also relates to a pre-existing issue where the api_key from the config file isn't passed to the VLMRun client. I suggest resolving both api_key and base_url from the config file before initializing the client to ensure consistent and predictable behavior.

Suggested change
# Chat subcommand uses the Agent API; use agent base URL when none set
client_base_url = base_url
if ctx.invoked_subcommand == "chat" and client_base_url is None:
client_base_url = DEFAULT_AGENT_BASE_URL
ctx.obj = VLMRun(api_key=api_key, base_url=client_base_url)
# Chat subcommand uses the Agent API; use agent base URL when none set
config = get_config()
resolved_api_key = api_key or config.api_key
client_base_url = base_url or config.base_url
if ctx.invoked_subcommand == "chat" and client_base_url is None:
client_base_url = DEFAULT_AGENT_BASE_URL
ctx.obj = VLMRun(api_key=resolved_api_key, base_url=client_base_url)

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