Files

96 lines
3.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Kipinä CodeBench
LLM-koodingenerointibenchmark. Testaa Ollama-mallien kykyä generoida toimivia FastAPI+SQLAlchemy-projekteja ja ajaa testit Docker-kontissa.
## Pikastart
```bash
# 1. Rakenna Docker-testikontti
docker build -t kipina-pytest -f Dockerfile.pytest .
# 2. Aja benchmark
node benchmark.mjs --ollama http://localhost:11434 --scenarios all
# 3. Avaa raportti
open /tmp/kipina-benchmark/report.html
```
## Pipeline
```
1. LLM → vaatimusmäärittely (prompts/client.md)
2. LLM → JSON-speksi (prompts/spec.md)
3. LLM → 4 Python-tiedostoa (prompts/code.md + golden-examples/)
4. Staattinen validointi + LLM-korjaus (prompts/fix.md)
5. Docker: uv init + uv add + pytest
```
## CLI-argumentit
| Argumentti | Oletus | Kuvaus |
|-----------|--------|--------|
| `--ollama` | `http://localhost:11434` | Ollama-palvelimen URL |
| `--hub` | - | Hub-reitti (vaihtoehto Ollamalle) |
| `--models` | kaikki | Pilkuilla erotettu mallilista |
| `--scenarios` | `default` (todo) | `all` = todo, users, blog |
| `--output` | `/tmp/kipina-benchmark` | Tuloshakemisto |
## Hakemistorakenne
```
kipina-codebench/
├── benchmark.mjs ← runner
├── Dockerfile.pytest ← Python 3.14 + uv testikontti
├── report-template.html ← HTML-raporttipohja
├── package.json
├── prompts/ ← muokattavat promptit
│ ├── client.md ← vaatimusmäärittely
│ ├── spec.md ← JSON-speksi
│ ├── code.md ← koodigenerointi
│ └── fix.md ← korjaus
├── golden-examples/ ← referenssitoteutukset
│ ├── todo/ ← taso 1: perus-CRUD (6 testiä)
│ ├── blog/ ← taso 2: relaatiot (13 testiä)
│ └── DOCUMENTATION.md ← zensical-dokumentointiohjeet
└── results/ ← tallennetut tulokset
```
## Promptien muokkaus
Promptit ovat `prompts/`-kansiossa Markdown-tiedostoina. Muokkaa suoraan — benchmark lataa ne käynnistyksessä.
Esimerkki: lisää sääntö `prompts/code.md`:hen:
```
- Tests: PUT/update test data MUST include ALL required fields
```
## Kultaiset esimerkit
`golden-examples/todo/` syötetään LLM:lle referenssinä. Malli näkee tarkalleen millaista koodia odotetaan:
- SQLAlchemy 2.0 (DeclarativeBase, Mapped, mapped_column)
- Pydantic v2 (ConfigDict)
- Python 3.14 syntaksi (str | None)
- Uniikki testidata per testi
Lisää uusia esimerkkejä luomalla hakemisto (esim. `golden-examples/shop/`).
## Pisteytys
| Komponentti | Pisteet | Peruste |
|---|---|---|
| Speksi OK | 10p | JSON-speksi onnistui |
| Koodi generoitu | 10p | Kaikki 4 tiedostoa syntyneet |
| Testit | 060p | passed/total × 60 |
| Korjaukset | 020p | 0 kierrosta = 20p, 1 = 10p, 2+ = 0p |
Tähdet: ★★★★★ (90+), ★★★★☆ (70+), ★★★☆☆ (50+), ★★☆☆☆ (25+), ★☆☆☆☆ (1+)
## Käyttö git-submodulena
```bash
git submodule add <repo-url> tools/codebench
cd tools/codebench
docker build -t kipina-pytest -f Dockerfile.pytest .
node benchmark.mjs --ollama http://localhost:11434 --scenarios all
```