Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/SoakpProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,17 @@ export class SoakpProxy {
* @param jobId
*/
async cancelFineTuneJob(jobId: string) {
return await this.openai.cancelFineTune(jobId);
}
async uploadFineTuneFile(file: any, purpose: string = 'fine-tune') {
try {
// Add error handling for other types of errors
return await this.openai.createFile(file, purpose);
} catch (err: any) {
console.log(err);
if (err instanceof TypeError) {
throw new Error(err.message);
} else {
throw err;
}
}
}
}
11 changes: 11 additions & 0 deletions src/openai/OpenaiFilesApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,15 @@ export class OpenaiFilesApi {
}
return buffer;
}

/**
* Convert a file to JSONL format.
*
* @param file
*/
async convertToJSONL(file: any) {
// Implement the Python code to convert the file to JSONL format
// This code will depend on the specific requirements and the Python library used
// ...
}
}
5 changes: 5 additions & 0 deletions src/openai/OpenaiFinetunesApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ export class OpenaiFinetunesApi {
validateToken(ctx.jwtHash, ctx.getKeyStorage(), ctx.getUser()),
getProxyInstance(ctx),
this.cancelJob.bind(ctx));

this.appService.post('/openai/fine-tunes/upload',
validateToken(ctx.jwtHash, ctx.getKeyStorage(), ctx.getUser()),
getProxyInstance(ctx),
this.uploadFineTuneFile.bind(ctx));
}

/**
Expand Down