Skip to content

Fix: add new default moonshot model - #17106

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
Lynn-Inf:fix/moonshot-default-model
Jul 20, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
Lynn-Inf:fix/moonshot-default-model

Conversation

@Lynn-Inf

Copy link
Copy Markdown
Contributor

Summary

As title.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 20, 2026
@Lynn-Inf Lynn-Inf added the ci Continue Integration label Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds three Moonshot chat models and updates streaming API-key verification to use temperature 1 for two Kimi models and 0.9 for others.

Changes

Moonshot model support

Layer / File(s) Summary
Model registration and verification
conf/llm_factories.json, api/apps/services/provider_api_service.py
Registers kimi-k3, kimi-k2.6, and kimi-k2.7-code as Moonshot chat models, and applies model-specific streaming temperatures during verification.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: buua436, wangq8

Poem

A rabbit hops through models bright,
Three Kimi names join the flight.
Stream temperatures softly tune,
One and two point nine bloom beneath the moon.
~(=^・ω・^)

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is too vague and only repeats the title, so it lacks the required summary and context. Expand the Summary with the problem, why the Moonshot model is being added, and any relevant behavior changes or impact.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding a default Moonshot model.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Lynn-Inf
Lynn-Inf requested a review from wangq8 July 20, 2026 08:46

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
api/apps/services/provider_api_service.py (1)

720-726: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Log 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9d850e7 and f136e0f.

📒 Files selected for processing (2)
  • api/apps/services/provider_api_service.py
  • conf/llm_factories.json

Comment thread conf/llm_factories.json
Comment on lines +1809 to +1829
{
"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
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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.json

Repository: 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:


🏁 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)
PY

Repository: 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.json

Repository: 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:


🏁 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)
PY

Repository: 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.go

Repository: 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.json

Repository: 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.py

Repository: 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.go

Repository: infiniflow/ragflow

Length of output: 10169


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '230,270p' common/settings.py

Repository: 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)
PY

Repository: infiniflow/ragflow

Length of output: 497


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,220p' internal/service/llm.go

Repository: 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.py

Repository: 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

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (3da2425) to head (f136e0f).
⚠️ Report is 22 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

  1. 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)".

  2. 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.

  3. kimi-k2.6 max_tokens: 262144 (256k) — worth confirming this matches the actual model limit from the Moonshot API.

  4. 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.

@Lynn-Inf Lynn-Inf changed the title Fix: add default moonshot model Fix: add new default moonshot model Jul 20, 2026
@wangq8
wangq8 merged commit 9a2a3c0 into infiniflow:main Jul 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants