Hello guys. I have been trying to fine tune a model but can’t get it to work.
So I tried the basics with a normal cURL completion and it worked perfectly, just like this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://api.openai.com/v1/completions”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ‘{
“model”: “text-davinci-003”,
“prompt”: “Hello”,
“max_tokens”: 50,
“temperature”: 0.2,
“top_p”: 1,
“frequency_penalty”: 0,
“presence_penalty”: 0
}’);
curl_setopt($ch, CURLOPT_POST, 1);$headers = array();
$headers = “Content-Type: application/json”;
$headers = “Authorization: Bearer sk-???”;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);$result = curl_exec($ch);
if (curl_errno($ch)) {
echo ‘Error:’ . curl_error($ch);
}
curl_close ($ch);echo $result;
But when I tried to upload a .jsonl file for fine-tuning it just won’t work and I don’t really know what is wrong with the code.
$headers = array();
$headers = “Content-Type: multipart/form-data”;
$headers = “Authorization: Bearer sk-???”;$c_file = “…/tests/chatgpt.jsonl”;
$opts = array(‘purpose’ => ‘fine-tune’, ‘file’ => $c_file);
$post_fields = json_encode($opts);$ch = curl_init();
$curl_info = [
CURLOPT_URL => “https://api.openai.com/v1/files”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => ‘’,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => $post_fields,
CURLOPT_HTTPHEADER => $headers,
];curl_setopt_array($ch, $curl_info);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo ‘Error:’ . curl_error($ch);
}
curl_close($ch);echo $result;
I get this error:
{ “error”: { “message”: “‘file’ is a required property”, “type”: “invalid_request_error”, “param”: null, “code”: null } }
This is the chatgpt.jsonl file:
{“prompt”: “Prompt 1”, “completion”: “Completion 1”}
{“prompt”: “Prompt 2”, “completion”: “Completion 2”}
I have tried numerous ways but it just won’t work, please help me out.