Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

feat: add support for Moonshot AI's Kimi K2 Thinking model#111

Merged
dragos199993 merged 4 commits into
mainfrom
ENG-3998_support-kimi-k2-thinking
Nov 19, 2025
Merged

feat: add support for Moonshot AI's Kimi K2 Thinking model#111
dragos199993 merged 4 commits into
mainfrom
ENG-3998_support-kimi-k2-thinking

Conversation

@dragos199993

@dragos199993 dragos199993 commented Nov 12, 2025

Copy link
Copy Markdown
Member
  • Introduced MOONSHOT_API_KEY in settings.py for API integration.
  • Updated providers.py to include KIMI_K2_THINKING model under Moonshot AI.
  • Enhanced client.py to handle requests for the Moonshot AI provider.
  • Added comprehensive tests for Kimi K2 Thinking model, covering streaming, response models, and tool calling functionalities.

Note

Adds Moonshot AI’s Kimi K2 Thinking model with settings/env wiring, client routing, and tests for streaming, response models, and tool calling.

  • LLM support:
    • Add moonshotai provider in notdiamond/settings.py with MOONSHOT_API_KEY, model kimi-k2-thinking, tool/response-model support, openrouter_identifier, and pricing.
    • Extend NDLLMProviders with KIMI_K2_THINKING.
    • Update _llm_from_config in notdiamond/llms/client.py to use ChatOpenAI with openai_api_base="https://api.moonshot.cn/v1" for moonshotai.
  • Tests:
    • Add tests/test_llm_calls/test_moonshotai.py covering streaming (sync/async), response model parsing, and tool calling (including OpenAI-style).

Written by Cursor Bugbot for commit df290dc. Configure here.

- Introduced MOONSHOT_API_KEY in settings.py for API integration.
- Updated providers.py to include KIMI_K2_THINKING model under Moonshot AI.
- Enhanced client.py to handle requests for the Moonshot AI provider.
- Added comprehensive tests for Kimi K2 Thinking model, covering streaming, response models, and tool calling functionalities.
…tions

- Modified stream_chunks and astream_chunks functions to accept a max_chunks parameter, allowing for more flexible chunk consumption.
- Updated tests for Kimi K2 Thinking model to utilize the new max_chunks functionality and ensure proper handling of streaming responses.
@github-actions

github-actions Bot commented Nov 19, 2025

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  notdiamond
  settings.py
  notdiamond/llms
  client.py 1669
  providers.py
  notdiamond/toolkit/rag
  evaluation.py
  testset.py
  workflow.py
  tests
  helpers.py
  tests/test_llm_calls
  test_moonshotai.py
  tests/test_toolkit/rag
  test_data_gen.py
  test_example_workflow.py
Project Total  

This report was generated by python-coverage-comment-action

Comment thread tests/helpers.py
@@ -1,24 +1,26 @@
def stream_chunks(ichunk):
def stream_chunks(ichunk, max_chunks=5):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I had to do this because this model is "thinking" out loud and it just spams the chunks

@dragos199993 dragos199993 merged commit 019b9d7 into main Nov 19, 2025
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants