[Model] Add Kimi K3 support: Python frontend [2/2] (#50093)

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
This commit is contained in:
Bugen Zhao
2026-07-29 01:06:01 -07:00
committed by GitHub
parent 6370e53f24
commit f5a7cce9b6
20 changed files with 3056 additions and 5 deletions
+8 -2
View File
@@ -2024,13 +2024,19 @@ def get_history_tool_calls_cnt(conversation: list[ConversationMessage]):
return idx
_KIMI_MODEL_TYPES = ("kimi_k2", "kimi_k25")
_KIMI_MODEL_TYPES = ("kimi_k2", "kimi_k25", "kimi_k3")
def get_tool_call_id_type(model_config: ModelConfig) -> str:
"""Return the tool-call ID type for a given model configuration."""
hf_overrides = getattr(model_config, "hf_overrides", None)
if model_config.hf_text_config.model_type in _KIMI_MODEL_TYPES or (
hf_config = getattr(model_config, "hf_config", None)
hf_text_config = getattr(model_config, "hf_text_config", None)
model_types = (
getattr(hf_config, "model_type", None),
getattr(hf_text_config, "model_type", None),
)
if any(model_type in _KIMI_MODEL_TYPES for model_type in model_types) or (
isinstance(hf_overrides, dict)
and hf_overrides.get("model_type") in _KIMI_MODEL_TYPES
):
@@ -565,6 +565,12 @@ class ChatCompletionRequest(OpenAIBaseModel):
),
media_io_kwargs=self.media_io_kwargs,
return_assistant_tokens_mask=bool(self.return_assistant_tokens_mask),
# No-tools requests default to tool_choice="none" at the API
# layer. Collapse that default before rendering, so K3 emits a
# model-visible tool-choice instruction only for requests with a
# tools block.
tool_choice=self.tool_choice if self.tools else None,
response_format=self.response_format,
)
def build_tok_params(self, model_config: ModelConfig) -> TokenizeParams:
@@ -337,6 +337,7 @@ class ResponsesRequest(OpenAIBaseModel):
extra_kwargs,
),
media_io_kwargs=self.media_io_kwargs,
tool_choice=self.tool_choice if self.tools else None,
)
def build_tok_params(self, model_config: ModelConfig) -> TokenizeParams: