-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add MoonshotAI provider with Kimi-K2 model support #2211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add MoonshotAI provider with Kimi-K2 model support #2211
Conversation
@zachmayer Thanks Zach! As you suggested, can you please split this up into separate PRs so the more straightforward ones can be merged more quickly? Pretty commit history is not that important, we'll end up squashing on merge anyway. Also, from the Maybe we can keep this PR for the MoonshotAIProvider as I already started talking about it :) |
- Add MoonshotAIProvider with OpenAI-compatible API - Implements OpenAI-style interface with custom base URL - Supports tool definitions but not strict tool validation - Add moonshotai:kimi-k2-0711-preview as known model - Configure to use OpenAIModel for compatibility - Add comprehensive tests for provider functionality - Update CLI and model name tests
4c4ebf7
to
dcd7d87
Compare
I made 2 PRs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zachmayer Thank you! In addition to these comments, can you please add some docs?
PR Change SummaryAdded a new MoonshotAI provider to support Kimi-K2 models, enhancing compatibility with OpenAI's API.
Modified Files
How can I customize these reviews?Check out the Hyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add |
I added a moonshot example to the open ai docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you look at the merge conflict as well please?
I'll make these updates and fix the conflicts. |
@DouweM Ok, I think I covered all your feedback! let me know how it looks. |
|
openai_client: AsyncOpenAI | None = None, | ||
http_client: AsyncHTTPClient | None = None, | ||
) -> None: | ||
api_key = api_key or os.getenv('MOONSHOT_API_KEY') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but I think the prefix here should be consistent with the class name, so either MOONSHOTAI_API_KEY
, or MoonshotProvider
. I wouldn't mind the latter, as we also have e.g. TogetherProvider
instead of TogetherAIProvider
. But then again most/all providers seem to use the moonshotai/
prefix for model names, so perhaps MOONSHOTAI_API_KEY
is best.
openai_supports_sampling_settings=True, | ||
) | ||
|
||
monkeypatch.setattr(OpenAIModelProfile, 'from_profile', fake_from_profile, raising=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bit more brittle mocking and monkeypatching here than I'd like, can we build a real OpenAIModelProfile
with the options we want, and actually pass that to OpenAIModel(..., profile=...)
?
Also this should be on tests/models/test_openai.py
! See test_model_profile_strict_not_supported
for an example.
This PR adds a new MoonshotAI provider for Kimi models.
Related PRs:
Changes
The provider follows the same pattern as other OpenAI-compatible providers like DeepSeek and Grok.
As requested by @DouweM, I've split the original large PR into 3 focused PRs for easier review.