CodeBench: --boss orkestroija — iso malli analysoi, pieni korjaa
- --boss + --boss-ollama: iso malli tekee spekin JA analysoi käännösvirheet
- Boss muotoilee selkeät korjausohjeet ("add import X, change line Y")
- Worker (pieni malli) toteuttaa korjauksen täsmällisen ohjeen perusteella
- Boss ei generoi koodia itse — vain analysoi ja ohjaa
This commit is contained in:
@@ -40,6 +40,8 @@ const SPEC_MODEL = arg('spec-model', ''); // Eri malli spec-vaiheille (1-2)
|
|||||||
const SPEC_OLLAMA = arg('spec-ollama', ''); // Eri Ollama spec-mallille
|
const SPEC_OLLAMA = arg('spec-ollama', ''); // Eri Ollama spec-mallille
|
||||||
const CONVERT_MODEL = arg('convert-model', ''); // Malli Python→Go/Rust konvertointiin
|
const CONVERT_MODEL = arg('convert-model', ''); // Malli Python→Go/Rust konvertointiin
|
||||||
const CONVERT_OLLAMA = arg('convert-ollama', ''); // Eri Ollama konvertointimallille
|
const CONVERT_OLLAMA = arg('convert-ollama', ''); // Eri Ollama konvertointimallille
|
||||||
|
const BOSS_MODEL = arg('boss', ''); // Orkestroija: spec + virheen analysointi
|
||||||
|
const BOSS_OLLAMA = arg('boss-ollama', ''); // Orkestroijan Ollama-instanssi
|
||||||
const LANG = arg('lang', 'python'); // python | rust | go
|
const LANG = arg('lang', 'python'); // python | rust | go
|
||||||
const ROUNDS = parseInt(arg('rounds', '1')); // 1-10 toistoa
|
const ROUNDS = parseInt(arg('rounds', '1')); // 1-10 toistoa
|
||||||
const MAX_FIX_ROUNDS = 2;
|
const MAX_FIX_ROUNDS = 2;
|
||||||
@@ -377,9 +379,10 @@ async function runPipeline(model, scenario, round = 1) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 1. Vaatimukset
|
// 1. Vaatimukset
|
||||||
const specModel = SPEC_MODEL || model;
|
const specModel = BOSS_MODEL || SPEC_MODEL || model;
|
||||||
console.log(` [1/5] Vaatimukset${SPEC_MODEL ? ` (${SPEC_MODEL})` : ''}...`);
|
const specUrl = BOSS_OLLAMA || SPEC_OLLAMA || null;
|
||||||
const specUrl = SPEC_OLLAMA || null;
|
const bossUrl = BOSS_OLLAMA || null;
|
||||||
|
console.log(` [1/5] Vaatimukset${specModel !== model ? ` (${specModel})` : ''}...`);
|
||||||
const req = await ollamaChat(specModel, scenario.prompt, CLIENT_SYSTEM, 2048, specUrl);
|
const req = await ollamaChat(specModel, scenario.prompt, CLIENT_SYSTEM, 2048, specUrl);
|
||||||
timings.push(req);
|
timings.push(req);
|
||||||
if (!req.text || req.text.length < 50) { result.error = 'Vaatimukset liian lyhyet'; return result; }
|
if (!req.text || req.text.length < 50) { result.error = 'Vaatimukset liian lyhyet'; return result; }
|
||||||
@@ -482,7 +485,20 @@ async function runPipeline(model, scenario, round = 1) {
|
|||||||
|
|
||||||
for (const fname of filesToFix) {
|
for (const fname of filesToFix) {
|
||||||
const errors = errorsByFile[fname].slice(0, 10).join('\n');
|
const errors = errorsByFile[fname].slice(0, 10).join('\n');
|
||||||
const fixPrompt = `Fix the following Go compilation errors in "${fname}". Return ONLY the corrected file, no explanations.\n\nERRORS:\n${errors}\n\nCURRENT FILE:\n${files[fname]}\n\nOTHER FILES:\n${Object.entries(files).filter(([f]) => f !== fname).map(([f, c]) => `=== ${f} ===\n${c}`).join('\n\n')}`;
|
let fixPrompt;
|
||||||
|
|
||||||
|
if (BOSS_MODEL) {
|
||||||
|
// Boss analysoi virheen ja muotoilee selkeän ohjeen workerille
|
||||||
|
console.log(` [3/5] → ${fname} (boss analyzes)...`);
|
||||||
|
const analysisResp = await ollamaChat(BOSS_MODEL,
|
||||||
|
`These Go compilation errors occurred in "${fname}":\n${errors}\n\nThe file currently contains:\n${files[fname]}\n\nExplain in 2-3 bullet points what specific changes need to be made. Be exact: which line, what to add/remove/change.`,
|
||||||
|
'You are a Go expert. Give precise fix instructions, no code.', 512, bossUrl);
|
||||||
|
timings.push(analysisResp);
|
||||||
|
fixPrompt = `Apply these fixes to "${fname}". Return ONLY the corrected file, no explanations.\n\nFIX INSTRUCTIONS:\n${analysisResp.text}\n\nCURRENT FILE:\n${files[fname]}`;
|
||||||
|
} else {
|
||||||
|
fixPrompt = `Fix the following Go compilation errors in "${fname}". Return ONLY the corrected file, no explanations.\n\nERRORS:\n${errors}\n\nCURRENT FILE:\n${files[fname]}\n\nOTHER FILES:\n${Object.entries(files).filter(([f]) => f !== fname).map(([f, c]) => `=== ${f} ===\n${c}`).join('\n\n')}`;
|
||||||
|
}
|
||||||
|
|
||||||
console.log(` [3/5] → ${fname} (fix)...`);
|
console.log(` [3/5] → ${fname} (fix)...`);
|
||||||
const fixResp = await ollamaChat(model, fixPrompt, CODE_SYSTEM, 2048);
|
const fixResp = await ollamaChat(model, fixPrompt, CODE_SYSTEM, 2048);
|
||||||
timings.push(fixResp);
|
timings.push(fixResp);
|
||||||
|
|||||||
Reference in New Issue
Block a user