Parannetut koodarin promptit + token-raja 512→1024

Koodarin prompti sisältää nyt:
- Import-vihjeen: "from models import ..." aiemmista tiedostoista
- Nimeämisvihjeen: Pydantic-schemat (UserCreate) vs SQLAlchemy (User)
- "Include all necessary imports. Write complete, working code."

Native-noden max_tokens nostettu 512→1024 jotta CRUD-endpointit
mahtuvat yhteen vastaukseen.

Testattu API:n kautta: 3B-malli tuottaa nyt oikeat importit,
erilliset Pydantic-schemat ja kaikki 5 CRUD-endpointtia.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaakko Vanhala
2026-04-09 21:56:24 +03:00
parent f7e0e8dff8
commit 009bf492c8
2 changed files with 11 additions and 2 deletions

View File

@@ -574,7 +574,16 @@ import AgentBar from "../components/AgentBar.astro";
if (prev.length) ctx = 'Already written:\n' + prev.map(([n,c]) => `--- ${n} ---\n${c}`).join('\n\n') + '\n\n';
let extra = '';
if (f.name === 'pyproject.toml') extra = '\nUse format: [project]\\nname="proj"\\nversion="0.1.0"\\nrequires-python=">=3.11"\\ndependencies=["fastapi","uvicorn"]';
const coderPrompt = (cdr.prompt ? cdr.prompt+'\n\n' : '') + `${ctx}Project: ${task}\nWrite ONLY "${f.name}"${f.desc ? ': '+f.desc : ''}.${extra}\nUse exact libraries from project description.`;
// Varmistetaan oikeat importit: listaa aiempien tiedostojen exportit
let importHint = '';
const prevNames = Object.keys(files);
if (prevNames.length > 0) {
importHint = '\n\nIMPORTANT: Import from already written files. ';
importHint += prevNames.map(n => `from ${n.replace('.py','')} import ...`).join(', ');
importHint += '. Use correct imports for all dependencies.';
importHint += '\nUse separate names for Pydantic schemas (e.g. UserCreate, UserResponse) vs SQLAlchemy models (e.g. User).';
}
const coderPrompt = (cdr.prompt ? cdr.prompt+'\n\n' : '') + `${ctx}Project: ${task}\nWrite ONLY "${f.name}"${f.desc ? ': '+f.desc : ''}.${extra}${importHint}\nInclude all necessary imports. Write complete, working code.`;
const code = await kpnRun(cdr.model, coderPrompt);
if (!code) { termLog(` ✗ Keskeytyi (${f.name})`, '#f85149'); return; }
files[f.name] = code;

View File

@@ -346,7 +346,7 @@ async fn main() {
if let Some(ref engine) = llm {
busy = true;
let max_tokens = task.get("max_tokens").and_then(|v| v.as_u64()).unwrap_or(512) as usize;
let max_tokens = task.get("max_tokens").and_then(|v| v.as_u64()).unwrap_or(1024) as usize;
tracing::info!("Generoidaan (task_id: {}, max_tokens: {}): \"{}\"", task_id, max_tokens, &prompt[..prompt.len().min(100)]);
let model_name = engine.model_name();