My experience is that it is best (less errors and headaches) to use the full path to the file in your File
API call.
/the/full/path/to/your/file/data_train.jsonl
The API error message are beta, hit or miss (mostly miss), so I discovered this “the hard way”.
Here is how I do it…as an example:
module Files
def self.get_client
Ruby::OpenAI.configure do |config|
config.access_token = ENV.fetch('OPENAI_API_KEY')
end
client = OpenAI::Client.new
end
def self.upload(filename="#{Rails.root}/app/assets/files/fine-tune.jsonl",purpose='fine-tune')
client = get_client
response =client.files.upload(
parameters: {
file: filename,
purpose: purpose,
})
file_id = JSON.parse(response.body)["id"]
file_id
end
end
Footnote
Please note @Arivald, even if your data passes JSONL validation, you must use a specific format in your text for fine-tuning. Your current JSONL text will pass JSONL but it will does not “pass” (there is no validator for this, but I have one), for the API requirements.
Most Developers Seem to Miss this Requirement
Reference: