Skip to content

feat(llm): support vertexai chat provider#497

Merged
stdrc merged 1 commit intomainfrom
rc/support-vertex-ai
Dec 18, 2025
Merged

feat(llm): support vertexai chat provider#497
stdrc merged 1 commit intomainfrom
rc/support-vertex-ai

Conversation

@stdrc
Copy link
Copy Markdown
Contributor

@stdrc stdrc commented Dec 18, 2025

No description provided.

Signed-off-by: Richard Chien <stdrc@outlook.com>
Copilot AI review requested due to automatic review settings December 18, 2025 05:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for Google Vertex AI as a chat provider and renames the Gemini Developer API provider type for clarity. The implementation switches the kosong dependency from PyPI to a Git source to access unreleased features needed for Vertex AI support.

Key Changes

  • Added new vertexai provider type using Google's Vertex AI service
  • Renamed google_genai provider to gemini for better clarity (maintaining backward compatibility)
  • Added env field to LLMProvider configuration for setting environment variables

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uv.lock Updated kosong dependency from PyPI (v0.33.0) to git source
pyproject.toml Added git source configuration for kosong package
src/kimi_cli/llm.py Added vertexai provider case, renamed google_genai to gemini with backward compatibility
src/kimi_cli/config.py Added optional env field to LLMProvider for environment variable configuration
CHANGELOG.md Documented new vertexai provider and gemini renaming

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

case "vertexai":
from kosong.contrib.chat_provider.google_genai import GoogleGenAI

os.environ.update(provider.env or {})
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

Modifying os.environ globally can have unintended side effects and affect other parts of the application. This approach pollutes the global environment and may cause issues with concurrent operations or when creating multiple LLM instances with different configurations. Consider passing environment variables directly to the GoogleGenAI constructor if it supports them, or use a context manager to temporarily set these variables only during initialization.

Copilot uses AI. Check for mistakes.
Comment on lines +138 to +147
case "vertexai":
from kosong.contrib.chat_provider.google_genai import GoogleGenAI

os.environ.update(provider.env or {})
chat_provider = GoogleGenAI(
model=model.model,
base_url=provider.base_url,
api_key=provider.api_key.get_secret_value(),
vertexai=True,
)
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

There is significant code duplication between the "gemini" and "vertexai" cases. The only differences are the env variable update and the vertexai parameter. Consider refactoring to reduce duplication, perhaps by extracting the common logic into a helper function or by handling both cases in a single block with conditional logic.

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +47
[tool.uv.sources]
kosong = { git = "https://github.com/MoonshotAI/kosong" }
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The dependency specification in pyproject.toml shows "kosong[contrib]==0.33.0" (line 12), but the git source doesn't specify a version or commit. This creates an inconsistency where the declared version (0.33.0) doesn't match the actual source being used. Consider either: 1) Updating the dependency to remove the version constraint since you're using git source, or 2) Adding a tag/ref to the git source to pin to a specific version for reproducibility.

Copilot uses AI. Check for mistakes.
@stdrc stdrc changed the title feat: support vertexai chat provider feat(llm): support vertexai chat provider Dec 18, 2025
@stdrc stdrc merged commit c7f6a97 into main Dec 18, 2025
15 checks passed
@stdrc stdrc deleted the rc/support-vertex-ai branch December 18, 2025 06:49
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.

2 participants