(projectRoot: string, messages: Message[])
| 69 | * logged and swallowed. A record with fewer than 2 turns (no real exchange) is skipped. |
| 70 | */ |
| 71 | export async function appendShareGptRecord(projectRoot: string, messages: Message[]): Promise<void> { |
| 72 | try { |
| 73 | const rec = toShareGpt(messages); |
| 74 | if (rec.conversations.length < 2) return; // nothing trainable |
| 75 | const full = datasetPath(projectRoot); |
| 76 | await fs.mkdir(path.dirname(full), { recursive: true }); |
| 77 | await fs.appendFile(full, JSON.stringify(rec) + '\n', 'utf-8'); |
| 78 | logger.info('Dataset record exported (ShareGPT)', { file: full, turns: rec.conversations.length }); |
| 79 | } catch (e: any) { |
| 80 | logger.debug('Dataset export skipped', { err: e?.message }); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /** Absolute path to a project's ShareGPT dataset (for fine-tune tooling). */ |
| 85 | export function getShareGptDatasetPath(projectRoot: string): string { |
no test coverage detected