# FineTune Helper

Local helper app for creating assignment-level fine-tuning records.

## Start

1. Copy `.env.example` to `.env`
2. Fill in the hosted AI endpoint, key, and model
3. Fill in the backend generator URL and teacher token
4. Run from repo root:

```bash
make fine-tune
```

Then open:

```text
http://localhost:4310
```

## What it does now

- generates a full assignment from the real backend `POST /api/questions/generate` endpoint using:
  - `topic`
  - `difficulty`
  - `count`
- stores the assignment in the same shape the real review flow expects:
  - assignment metadata
  - question list
  - student submission per question
  - teacher review per question
  - assignment summary
  - recommended next step
- can ask the hosted model to draft:
  - the full student submission for all questions
  - the full teacher review package for all questions plus assignment summary
- shows:
  - a canonical saved record preview
  - a chat-style fine-tune JSON preview
- saves reviewed examples locally in your browser
- lets you load, update, and delete saved examples
- exports either:
  - `dataset.jsonl`
  - `train.jsonl` + `val.jsonl`

## Saved record shape

The helper now targets one saved row per assignment:

```text
assignment-review-v1
  assignment
  studentSubmission
  teacherReview.questions[]
  teacherReview.assignmentSummary
  teacherReview.recommendedNextStep
```

This matches the real app's mixed-granularity review flow:

```text
one assignment review call
  -> question-level labels for every question
  -> one assignment-level summary
```

## Backend generator auth

Set:

- `FINE_TUNE_BACKEND_URL` to your BoostAI base URL, for example `https://boost.ai.moku.build`
- `FINE_TUNE_BACKEND_TOKEN` to a valid teacher JWT/session token value

The helper forwards that token as:

```text
Authorization: Bearer <token>
```

so it can call the protected backend generator endpoint from the separate local helper app.
