feat: Add Moonshot (Kimi) provider for K2.5 and legacy models#407
feat: Add Moonshot (Kimi) provider for K2.5 and legacy models#407howardpen9 wants to merge 1 commit intoBeehiveInnovations:mainfrom
Conversation
Add native Moonshot/Kimi provider following the existing XAI provider pattern. Supports Kimi K2.5 (262K context, extended thinking, vision) and legacy Moonshot V1 models (128K/32K). - Provider class with RegistryBackedProviderMixin + OpenAICompatibleProvider - JSON model config with 4 models and alias resolution - Model restrictions support via MOONSHOT_ALLOWED_MODELS - 15 comprehensive unit tests (all passing) Closes BeehiveInnovations#198 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, 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 significantly expands the platform's AI model capabilities by integrating native support for Moonshot (Kimi) models. It establishes a new provider, defines model configurations with aliases, and incorporates robust mechanisms for model selection and restriction. The changes ensure that Kimi's advanced models, including the K2.5, are fully accessible and manageable within the existing provider framework, enhancing the system's versatility and responsiveness to community requests. Highlights
🧠 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. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
The pull request successfully integrates Moonshot (Kimi) as a new first-class provider, following the established XAI provider pattern. The changes are comprehensive, covering environment variable configuration, model definition, provider implementation, and registry updates. The addition of 15 unit tests ensures the new provider's functionality, including initialization, model validation, capability retrieval, restriction handling, and crucial alias resolution before API calls. The code is clean, consistent with existing patterns, and appears to be well-structured. No issues, bugs, or improvement opportunities meeting the specified severity criteria (medium, high, critical) were identified.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27c0256a90
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ProviderType.OPENAI, # Direct OpenAI access | ||
| ProviderType.AZURE, # Azure-hosted OpenAI deployments | ||
| ProviderType.XAI, # Direct X.AI GROK access | ||
| ProviderType.MOONSHOT, # Direct Moonshot Kimi access |
There was a problem hiding this comment.
Wire Moonshot into centralized model restriction parsing
Adding Moonshot to provider priority means auto-mode selection and get_available_models(respect_restrictions=True) will consider Moonshot models, but ModelRestrictionService.ENV_VARS (in utils/model_restrictions.py) still has no ProviderType.MOONSHOT entry. In environments that set MOONSHOT_ALLOWED_MODELS, restricted Moonshot models are still advertised/selected and only fail later when request-time validation runs in OpenAICompatibleProvider._ensure_model_allowed, which can break auto-mode flows with avoidable runtime ValueErrors.
Useful? React with 👍 / 👎.
| def __init__(self, config_path: str | None = None) -> None: | ||
| super().__init__( | ||
| env_var_name="MOONSHOT_MODELS_CONFIG_PATH", | ||
| default_filename="moonshot_models.json", |
There was a problem hiding this comment.
Include moonshot_models.json in packaged data files
This registry depends on conf/moonshot_models.json, but the packaging manifest still enumerates only the older conf JSON files in [tool.setuptools.data-files] (pyproject.toml), so wheel installs omit the new Moonshot manifest. In a packaged deployment the provider will initialize with an empty model registry, causing Moonshot model listing/validation to fail even when MOONSHOT_API_KEY is configured.
Useful? React with 👍 / 👎.
|
123 |
Summary
Adds native Moonshot/Kimi as a first-class provider, following the existing XAI provider pattern exactly.
MoonshotModelProviderusingRegistryBackedProviderMixin+OpenAICompatibleProviderkimi-k2.5(262K ctx, thinking, vision),kimi-k2-0905-preview,moonshot-v1-128k,moonshot-v1-32kkimi→kimi-k2.5,moonshot→kimi-k2.5,moonshot-128k→moonshot-v1-128k, etc.MOONSHOT_ALLOWED_MODELSenv var supportMotivation
Community requested Kimi/Moonshot support (Issue #198). Moonshot API is OpenAI-compatible at
https://api.moonshot.cn/v1, making integration straightforward via the existingOpenAICompatibleProviderbase class.Kimi K2.5 is a 1T MoE model with 262K context, extended thinking, vision, and function calling — competitive with frontier models for code and reasoning tasks.
Changes
providers/moonshot.pyproviders/registries/moonshot.pyconf/moonshot_models.jsontests/test_moonshot_provider.pyproviders/shared/provider_type.pyMOONSHOTenum valueproviders/registry.pyproviders/__init__.pyserver.pyconfigure_providers().env.exampleMOONSHOT_API_KEYentryTest plan
pytest tests/test_moonshot_provider.py -v)code_quality_checks.shpasses (ruff + black + isort + tests)Closes #198
🤖 Generated with Claude Code