1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { delay } from "https://esm.town/v/stevekrouse/delay";
import { openaiFineTune } from "https://esm.town/v/stevekrouse/openaiFineTune";
import { openaiUploadFile } from "https://esm.town/v/stevekrouse/openaiUploadFile?v=15";
export async function openaiFineTuneData({ key, data, model }: {
key: string;
data: any;
model?: string;
}) {
let upload = await openaiUploadFile({
key,
data,
});
let fineTune = await openaiFineTune({
key,
model,
trainingFile: upload.id,
});
let tries = 10;
while (fineTune.error?.message?.includes("is not ready") && tries-- > 0) {
console.log("File not ready, will try again in a second");
await delay(1000);
fineTune = await openaiFineTune({
key,
model,
trainingFile: upload.id,
});
}
return fineTune;
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.