Repository navigation
Fix: add new default moonshot model - #17106
Conversation
📝 WalkthroughWalkthroughAdds three Moonshot chat models and updates streaming API-key verification to use temperature ChangesMoonshot model support
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
api/apps/services/provider_api_service.py (1)
720-726: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLog the new model-specific verification behavior.
This branch introduces different temperatures for specific models. Add structured logging for the selected model and temperature, without logging API keys or other sensitive data.
As per coding guidelines,
**/*.py: Add logging for new flows.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/apps/services/provider_api_service.py` around lines 720 - 726, In the model verification flow containing check_streamly, add structured logging after selecting temperature that records the model name and chosen temperature. Use the existing logger for this module and exclude API keys, prompts, or any other sensitive data.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@conf/llm_factories.json`:
- Around line 1809-1829: Update the model_type field for kimi-k3, kimi-k2.6, and
kimi-k2.7-code in the LLM factory configuration from "chat" to ["image2text",
"chat"], preserving all other model metadata.
---
Nitpick comments:
In `@api/apps/services/provider_api_service.py`:
- Around line 720-726: In the model verification flow containing check_streamly,
add structured logging after selecting temperature that records the model name
and chosen temperature. Use the existing logger for this module and exclude API
keys, prompts, or any other sensitive data.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c79546f4-f13a-4aa5-80a0-6b568b98afbf
📒 Files selected for processing (2)
api/apps/services/provider_api_service.pyconf/llm_factories.json
| { | ||
| "llm_name": "kimi-k3", | ||
| "tags": "LLM,CHAT,1M", | ||
| "max_tokens": 1048576, | ||
| "model_type": "chat", | ||
| "is_tools": true | ||
| }, | ||
| { | ||
| "llm_name": "kimi-k2.6", | ||
| "tags": "LLM,CHAT,256k", | ||
| "max_tokens": 262144, | ||
| "model_type": "chat", | ||
| "is_tools": true | ||
| }, | ||
| { | ||
| "llm_name": "kimi-k2.7-code", | ||
| "tags": "LLM,CHAT,256k", | ||
| "max_tokens": 262144, | ||
| "model_type": "chat", | ||
| "is_tools": true | ||
| }, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf 'Repo files of interest:\n'
git ls-files conf/llm_factories.json | cat
printf '\nRelevant modality-discovery references:\n'
rg -n --hidden --no-ignore-vcs 'IMAGE2TEXT|image2text|model_type|tags' -g '!**/node_modules/**' -g '!**/dist/**' -g '!**/build/**' . | head -n 200
printf '\nSnippet around the target lines:\n'
sed -n '1790,1845p' conf/llm_factories.jsonRepository: infiniflow/ragflow
Length of output: 25100
🌐 Web query:
Moonshot Kimi K2.6 K2.7 Code visual input IMAGE2TEXT model_type docs
💡 Result:
Moonshot AI's Kimi K2.6 and K2.7 Code models are advanced, open-weight Mixture-of-Experts (MoE) models designed for agentic tasks, including software engineering and multimodal reasoning [1][2][3]. Both models support visual input, enabling capabilities such as image and video understanding [4][5][6]. Multimodal Integration and Usage The models support multimodal requests through the Moonshot AI API, which is compatible with the OpenAI API format [3][7][6]. When sending requests, you must use a JSON array for the message content rather than a serialized string [5]. The content structure requires an array of objects, where visual input is specified using the image_url or video_url type [5][7][6]: { "role": "user", "content": [ { "type": "text", "text": "Describe this image." }, { "type": "image_url", "image_url": { "url": "data:image/png;base64,..." } } ] } Supported formats include base64-encoded strings or references to uploaded file IDs [5][7]. For video, the API supports formats including mp4, mpeg, mov, avi, and webm [4]. Technical Overview - Kimi K2.6: Released in April 2026, this 1T parameter MoE model (with 32B active parameters) features a 256K context window and is optimized for general agentic tasks [1][2][3]. - Kimi K2.7 Code: Released in June 2026, this model is a specialized successor to K2.6 focused on coding [8][9][3]. It improves on real-world long-horizon coding performance and reduces thinking-token usage by approximately 30% compared to K2.6 [8][3][4]. - Architecture: Both models share the same architecture, allowing developers to reuse deployment configurations [8][3]. They are available via the Moonshot API, Hugging Face, and for self-hosting using engines like vLLM or SGLang [8][2][3]. Official documentation for these models can be found on the Kimi API Platform (platform.kimi.ai) and the respective Hugging Face model cards [8][1][5].
Citations:
- 1: https://huggingface.co/moonshotai/Kimi-K2.6
- 2: https://datanorth.ai/news/moonshot-ai-releases-kimi-k2-6
- 3: https://aiinsiders.net/article/moonshot-ai-ships-kimi-k27-code-a-1t-parameter-moe-drop-in
- 4: https://platform.kimi.ai/docs/guide/kimi-k2-7-code-quickstart
- 5: https://platform.kimi.ai/docs/guide/use-kimi-vision-model
- 6: https://platform.kimi.ai/docs/overview
- 7: https://platform.kimi.ai/docs/api/chat.md
- 8: https://huggingface.co/moonshotai/Kimi-K2.7-Code
- 9: https://x.com/Kimi_Moonshot/status/2065377579130142937?lang=en
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import json, re, pathlib
p = pathlib.Path('conf/llm_factories.json')
data = json.loads(p.read_text())
# find entries by llm_name
names = {'kimi-k3','kimi-k2.6','kimi-k2.7-code'}
for entry in data:
if entry.get('llm_name') in names:
print(entry['llm_name'], entry)
PYRepository: infiniflow/ragflow
Length of output: 281
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- target entries ---'
python3 - <<'PY'
import json, pathlib
data = json.loads(pathlib.Path('conf/llm_factories.json').read_text())
for name in ('kimi-k3','kimi-k2.6','kimi-k2.7-code'):
for e in data:
if e.get('llm_name') == name:
print(name, e)
PY
echo '--- modality references ---'
rg -n 'IMAGE2TEXT|image2text|model_type|tags' . --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' | sed -n '1,120p'Repository: infiniflow/ragflow
Length of output: 304
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import json, pathlib
data = json.loads(pathlib.Path('conf/llm_factories.json').read_text())
print(type(data))
if isinstance(data, dict):
print("top-level keys:", list(data.keys())[:20])
moon = data.get("Moonshot")
print("Moonshot type:", type(moon))
if isinstance(moon, dict):
print("Moonshot keys:", list(moon.keys()))
print("llm count:", len(moon.get("llm", [])))
for e in moon.get("llm", []):
if isinstance(e, dict) and e.get("llm_name") in {"kimi-k3","kimi-k2.6","kimi-k2.7-code"}:
print(e)
PY
printf '\nOther multimodal examples in conf/llm_factories.json:\n'
rg -n '"model_type":\s*\[' conf/llm_factories.json
rg -n '"IMAGE2TEXT"' conf/llm_factories.jsonRepository: infiniflow/ragflow
Length of output: 8303
🌐 Web query:
Moonshot Kimi K3 visual input image video support docs
💡 Result:
Moonshot AI's Kimi K3 is a natively multimodal model that supports image and video input [1][2]. It is designed for complex tasks including visual auditing, software engineering, and knowledge work [1][3]. Key details regarding visual and video support: Input Methods Kimi K3 supports images and videos via several methods [4]: - Base64 encoding: For images (e.g., data:image/png;base64,...) and videos (e.g., data:video/mp4;base64,...) [5]. - File Uploads: Uploading files to the Kimi platform to obtain an ms:// file ID, which is recommended for larger files [1][6][7]. - Note: Public URLs are generally not supported for vision input; users should use base64 encoding or file IDs [6][8]. Supported Formats - Images: PNG, JPEG, WebP, GIF [8][4]. - Videos: MP4, MPEG, MOV, AVI, X-FLV, MPG, WebM, WMV, 3GPP [8]. Technical Recommendations and Limits - Resolution: For optimal performance, images should be within 4K resolution (4096x2160) and videos within Full HD (1920x1080) [1][8]. - Request Size: The total request body size should not exceed 100MB [8]. - Implementation: When using the API, multimodal input is constructed by sending an array of objects in the content field, specifying the type as image_url or video_url [6][5][9]. Kimi K3's architecture treats these inputs within a unified framework, allowing it to process long-context materials and engage in agentic workflows that require visual feedback [10][2][11]. Detailed examples and API implementation guides are available in the official Kimi API documentation [1][6][5][8].
Citations:
- 1: https://platform.kimi.ai/docs/overview
- 2: https://automatio.ai/models/kimi-k3
- 3: https://platform.kimi.ai/docs/models
- 4: https://www.kimi.com/help/getting-started/agentic-chat
- 5: https://platform.kimi.ai/docs/api/chat.md
- 6: https://platform.kimi.ai/docs/guide/kimi-k3-quickstart
- 7: https://www.verdent.ai/guides/agents/kimi-k3-api-guide
- 8: https://platform.kimi.ai/docs/guide/use-kimi-vision-model
- 9: https://platform.kimi.ai/docs/api/chat
- 10: https://foundrysoft.co/blog/kimi-k3-multimodal-video-analysis
- 11: https://www.vp-land.com/p/moonshot-s-kimi-k3-makes-video-a-native-input-in-a-2-8-trillion-parameter-open-weights-model
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n 'llm_factories\.json|llm_factory|llm_factories' . --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**'
printf '\nJSON excerpt for provider-level Moonshot entry:\n'
python3 - <<'PY'
import json, pathlib
data = json.loads(pathlib.Path('conf/llm_factories.json').read_text())
if isinstance(data, dict):
moon = data.get('Moonshot')
print(moon)
PYRepository: infiniflow/ragflow
Length of output: 37058
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- api/apps/llm_app.py relevant section ---'
sed -n '480,555p' api/apps/llm_app.py
printf '\n%s\n' '--- web/src/pages/user-setting/setting-model/provider-schema/hooks/use-provider-fields.tsx relevant section ---'
sed -n '110,145p' web/src/pages/user-setting/setting-model/provider-schema/hooks/use-provider-fields.tsx
printf '\n%s\n' '--- web/src/pages/user-setting/setting-model/provider-schema/field-config/utils.ts relevant section ---'
sed -n '1,90p' web/src/pages/user-setting/setting-model/provider-schema/field-config/utils.ts
printf '\n%s\n' '--- internal/dao/database.go llm_factories structure ---'
sed -n '1,120p' internal/dao/database.goRepository: infiniflow/ragflow
Length of output: 11121
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- conf/llm_factories.json around first multimodal entries ---'
sed -n '250,330p' conf/llm_factories.json
printf '\n%s\n' '--- conf/llm_factories.json around another multimodal block ---'
sed -n '400,470p' conf/llm_factories.jsonRepository: infiniflow/ragflow
Length of output: 5447
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n '\bllm\[.*tags|\.tags\b.*llm|model_type.*tags|tags.*model_type|\"tags\":.*IMAGE2TEXT|\"tags\":.*CHAT' api internal web test conf --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**'Repository: infiniflow/ragflow
Length of output: 384
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- places that read per-model tags/model_type from factory config ---'
rg -n '"llm_name"|llm_factories\.json|FACTORY_LLM_INFOS|model_type|tags' api internal common tools web test --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' | sed -n '1,220p'
printf '\n%s\n' '--- seeding logic around conf/llm_factories.json ---'
sed -n '1230,1315p' tools/scripts/mysql_migration.pyRepository: infiniflow/ragflow
Length of output: 25582
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n 'LLMFactoriesFile|LLMFactoryConfig|LLMConfig|FactoryLLMInfos|factory_llm_infos|llm_factories\.json' internal api common tools web test --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' | sed -n '1,220p'Repository: infiniflow/ragflow
Length of output: 4469
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,220p' internal/service/llm.go
printf '\n--- later section if needed ---\n'
sed -n '220,420p' internal/service/llm.goRepository: infiniflow/ragflow
Length of output: 10169
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '230,270p' common/settings.pyRepository: infiniflow/ragflow
Length of output: 1970
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n 'FACTORY_LLM_INFOS|settings\.FACTORY_LLM_INFOS|get_all\(' internal/service common api web --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**'Repository: infiniflow/ragflow
Length of output: 4875
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import json, pathlib
data = json.loads(pathlib.Path('conf/llm_factories.json').read_text())
for factory in data['factory_llm_infos']:
if factory['name'] == 'Moonshot':
for llm in factory['llm']:
if llm['llm_name'] in {'kimi-k3','kimi-k2.6','kimi-k2.7-code'}:
print(llm)
PYRepository: infiniflow/ragflow
Length of output: 497
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,220p' internal/service/llm.goRepository: infiniflow/ragflow
Length of output: 5836
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n 'FACTORY_LLM_INFOS|settings\.FACTORY_LLM_INFOS|factory_llm_infos|model_type.*image2text|image2text' internal/service common api web --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**'Repository: infiniflow/ragflow
Length of output: 8823
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- api/apps/services/models_api_service.py around FACTORY_LLM_INFOS usage ---'
sed -n '160,220p' api/apps/services/models_api_service.py
printf '\n%s\n' '--- api/apps/services/models_api_service.py later usage ---'
sed -n '320,360p' api/apps/services/models_api_service.py
printf '\n%s\n' '--- api/apps/services/provider_api_service.py relevant sections ---'
sed -n '70,140p' api/apps/services/provider_api_service.py
sed -n '170,260p' api/apps/services/provider_api_service.pyRepository: infiniflow/ragflow
Length of output: 13249
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n 'model_type|model_types|image2text|vision|FACTORY_LLM_INFOS' api/apps/services/models_api_service.py api/apps/services/provider_api_service.py --glob '!**/node_modules/**'Repository: infiniflow/ragflow
Length of output: 14306
Mark these Moonshot models as multimodal.
kimi-k3, kimi-k2.6, and kimi-k2.7-code support visual input, but they’re still declared as model_type: "chat" in conf/llm_factories.json. provider_api_service.py derives model-type availability from this field, so switch each to ["image2text", "chat"] to surface the vision path.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@conf/llm_factories.json` around lines 1809 - 1829, Update the model_type
field for kimi-k3, kimi-k2.6, and kimi-k2.7-code in the LLM factory
configuration from "chat" to ["image2text", "chat"], preserving all other model
metadata.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17106 +/- ##
=======================================
Coverage 90.65% 90.65%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 650 650
Misses 39 39
Partials 28 28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wangq8
left a comment
There was a problem hiding this comment.
Review: PR #17106 – Add default moonshot models
Overview: This PR adds three new Kimi/Moonshot models (kimi-k3, kimi-k2.6, kimi-k2.7-code) to the LLM factory config and adjusts the temperature used during API key verification for kimi-k3 and kimi-k2.7-code to 1.0 (from the default 0.9).
What looks good
- The model config entries follow the existing pattern and include appropriate metadata (context size, tool support, tags).
- The temperature change is restricted to the verify_api_key flow only — it won't affect production inference, just the connectivity check.
- The change is small and focused: 21 lines of config + 3 lines of logic.
Potential issues / questions
-
PR title vs scope: The title says "add default moonshot model" (singular), but the diff adds three models. Consider updating the title to reflect the full scope, e.g., "Add new Kimi models (k3, k2.6, k2.7-code)".
-
kimi-k2.6 tool support: is_tools is set to true for kimi-k2.6. Is it confirmed that the k2.6 API supports function/tool calling? If not, this could produce confusing errors for users.
-
kimi-k2.6 max_tokens: 262144 (256k) — worth confirming this matches the actual model limit from the Moonshot API.
-
Why no temperature change for k2.6? The PR adjusts temperature for k3 (1.0) and k2.7-code (1.0), but not for k2.6 (still 0.9). Was this intentional? A brief comment explaining why would help reviewers.
Minor
- The conf/llm_factories.json diff places the new entries above the existing kimi-thinking-preview entry. If there is a convention for ordering (alphabetical, release order), it may be worth checking.
Summary
A clean, low-risk change. The new model entries look correct structurally. Just a few clarity questions above. No regressions or security concerns detected.
Summary
As title.