CodeBench: --spec-ollama lippu eri Ollama-instanssille spec-vaiheissa

This commit is contained in:
2026-04-14 23:05:07 +03:00
parent 3caefa2f6e
commit 1649d2e864

View File

@@ -36,6 +36,7 @@ const THINK_MODE = args.includes('--think');
const COMPACT_MODE = args.includes('--compact');
const NO_ORCHESTRATE = args.includes('--no-orchestrate');
const SPEC_MODEL = arg('spec-model', ''); // Eri malli spec-vaiheille (1-2)
const SPEC_OLLAMA = arg('spec-ollama', ''); // Eri Ollama spec-mallille
const LANG = arg('lang', 'python'); // python | rust | go
const ROUNDS = parseInt(arg('rounds', '1')); // 1-10 toistoa
const MAX_FIX_ROUNDS = 2;
@@ -135,7 +136,7 @@ function stripThinking(text) {
}
// === Ollama / Hub -client ===
async function ollamaChat(model, prompt, systemPrompt, maxTokens = 2048) {
async function ollamaChat(model, prompt, systemPrompt, maxTokens = 2048, ollamaUrl = null) {
const start = Date.now();
if (HUB_URL) {
@@ -161,7 +162,7 @@ async function ollamaChat(model, prompt, systemPrompt, maxTokens = 2048) {
if (systemPrompt) messages.push({ role: 'system', content: systemPrompt });
messages.push({ role: 'user', content: prompt });
const resp = await fetch(`${OLLAMA_URL}/api/chat`, {
const resp = await fetch(`${ollamaUrl || OLLAMA_URL}/api/chat`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@@ -332,7 +333,8 @@ async function runPipeline(model, scenario, round = 1) {
// 1. Vaatimukset
const specModel = SPEC_MODEL || model;
console.log(` [1/5] Vaatimukset${SPEC_MODEL ? ` (${SPEC_MODEL})` : ''}...`);
const req = await ollamaChat(specModel, scenario.prompt, CLIENT_SYSTEM, 2048);
const specUrl = SPEC_OLLAMA || null;
const req = await ollamaChat(specModel, scenario.prompt, CLIENT_SYSTEM, 2048, specUrl);
timings.push(req);
if (!req.text || req.text.length < 50) { result.error = 'Vaatimukset liian lyhyet'; return result; }
result.reqOk = true;
@@ -342,7 +344,7 @@ async function runPipeline(model, scenario, round = 1) {
const specProfile = PROFILES.models[specModel]?.profile || PROFILES.default_profile;
const specPrompt = specProfile === 'small' ? SPEC_SIMPLE_SYSTEM : SPEC_SYSTEM;
console.log(` [2/5] JSON-speksi${specProfile === 'small' ? ' (simple)' : ''}...`);
const specResp = await ollamaChat(specModel, `${req.text}\n\nOutput a JSON spec for this project.`, specPrompt, 4096);
const specResp = await ollamaChat(specModel, `${req.text}\n\nOutput a JSON spec for this project.`, specPrompt, 4096, specUrl);
timings.push(specResp);
const spec = extractJson(specResp.text);
if (!spec || !spec.entities || spec.entities.length === 0) { result.error = 'JSON-speksi epäonnistui'; writeFileSync(`${dir}/_spec_raw.txt`, specResp.text); return result; }