I am trying to upload jsonl file for the purpose of fine-tuning. But after spending multiple days I am lost.
I constantly receiver error:
error: SyntaxError: Unexpected token 'e', "error: ENOENT" is not valid JSON at JSON.parse (<anonymous>…, text: 'error: ENOENT'}
This is the content of my training set:
{"prompt":"aaa ->","completion":" bbb END"}
{"prompt":"bbb ->","completion":" cccc END"}
The name of the file is trainingfile.jsonl. If I knew how, i would upload it here.
Here is code from my angular project that prepares the training file:
let tf = '{"prompt":"aaa ->","completion":" bbb END"}\n{"prompt":"bbb ->","completion":" cccc END"}'
var blob = new Blob([tf], { type: 'application/jsonl; charset=utf-8' });
var file = new File([blob], "trainingfile.jsonl", { type: 'application/jsonl; charset=utf-8' });
let currentFileUpload = new FileUpload(file, file.name, this.projectKey);
currentFileUpload.url = this.projectKey // this is a key used by user
const uploadTask = this.upload.pushFileToStorage(this.userId, currentFileUpload, "/trainingfiles/")
uploadTask.on('state_changed',
(snapshot) => { },
() => {
if (file.type.includes("jsonl")) {
let path = uploadTask.snapshot.metadata.fullPath
const storage = getStorage();
const imageRef = refStorage(storage, path);
getDownloadURL(imageRef)
.then((url) => {
this.firestore.addFileToFirebase(this.userId, this.projectKey, this.projectKey, "content", this.userId, uploadTask.snapshot.metadata.name, uploadTask.snapshot.metadata.fullPath, uploadTask.snapshot.metadata.contentType as string, false, "content").then(() => {
this.http.get("https://<fire project id>/uploadFile", { params: {userId: this.userId, filePath: url} })
.subscribe((response: any) =>
{
console.log("returned from function uploadFile "+response)
});
})
})
}
}
)
Or maybe it is the problem with my firebase function (I use firebase function to communicate with openai api):
exports.uploadFile = onRequest({ cors: true }, async (request: any, response: any) => {
const filePath = request.query.filePath
if (!filePath) {
response.send("Please send query parameter!");
}
const res = openai.createFile(
fs.createReadStream(filePath),
"fine-tune"
).then(() => {
response.send(res)
})
});
To summarize my algorithm goes as follows:
- Preparing string containing training set
- Saving training set as jsonl file
- Sending the file to firebase storage
- Adding record of the file to firebase
- Launching firebase function uploadFile with url of the jsonl training file in the fire storage
- in firebase function sending url through stream to openai with use of createFile method