Conversation
Signed-off-by: Richard Chien <stdrc@outlook.com>
There was a problem hiding this comment.
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
vertexaiprovider type using Google's Vertex AI service - Renamed
google_genaiprovider togeminifor better clarity (maintaining backward compatibility) - Added
envfield toLLMProviderconfiguration 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 {}) |
There was a problem hiding this comment.
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.
| 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, | ||
| ) |
There was a problem hiding this comment.
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.
| [tool.uv.sources] | ||
| kosong = { git = "https://github.com/MoonshotAI/kosong" } |
There was a problem hiding this comment.
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.
No description provided.