mirror of
https://github.com/val1813/kwcode.git
synced 2026-09-03 06:34:30 +08:00
feat: wire model_capability into pipeline — tier-adaptive prompts + ctx auto-detect
Model tier detection now active (was orphaned code): - orchestrator.__init__: detect tier from generator.llm.ollama_model - ctx.model_tier written at run() start, flows to Generator - Generator._build_system(): SMALL gets strict format constraints (1 function, ≤10 lines, preserve indent, no explanation, ≤15 words between tools) LARGE gets minimal constraint; MEDIUM uses base rules as-is - _get_max_retries() respects model_strategy.max_retries Context window auto-detection (get_effective_ctx): - 4-layer probe: llama.cpp /props → vLLM /v1/models → Ollama modelinfo.llama.context_length → tier default - Passed to LLMBackend n_ctx in build_pipeline - SMALL=16K, MEDIUM=32K, LARGE=64K defaults; native ctx capped at 64K×0.8 501 tests green, 0 regression. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -71,10 +71,15 @@ def build_pipeline(model_path, ollama_url, ollama_model, project_root, verbose):
|
||||
_cfg = _load_cfg().get("default", {})
|
||||
_api_key = _cfg.get("api_key", "")
|
||||
|
||||
# Ctx自适应:检测模型可用上下文窗口
|
||||
from kaiwu.core.model_capability import get_effective_ctx
|
||||
effective_ctx = get_effective_ctx(ollama_model, ollama_url)
|
||||
|
||||
llm = LLMBackend(
|
||||
model_path=model_path,
|
||||
ollama_url=ollama_url,
|
||||
ollama_model=ollama_model,
|
||||
n_ctx=effective_ctx,
|
||||
verbose=verbose,
|
||||
api_key=_api_key,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user