type Openai = {
api_key: string;
organization_id: string;
};
/**
* List fine tune events
* Get fine-grained status updates for a fine-tune job.
*/
export async function main(
auth: Openai,
fine_tune_id: string,
stream: string | undefined
) {
const url = new URL(
`https://api.openai.com/v1/fine-tunes/${fine_tune_id}/events`
);
for (const [k, v] of [["stream", stream]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
"OpenAI-Organization": auth.organization_id,
Authorization: "Bearer " + auth.api_key,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 170 days ago