File size: 1,075 Bytes
97cfeff |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"\n",
"# Save formatted_data as JSONL\n",
"with open(\"mydata.jsonl\", \"w\") as outfile:\n",
" for entry in formatted_data:\n",
" json.dump(entry, outfile)\n",
" outfile.write(\"\\n\")\n",
"\n",
"# Now use it in the provided code\n",
"import os\n",
"import openai\n",
"\n",
"openai.api_key = '' ##add API key here\n",
"openai.File.create(\n",
" file=open(\"mydata.jsonl\", \"rb\"),\n",
" purpose='fine-tune'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"openai.FineTuningJob.create(training_file=\"file-XMpA2lwxpHwIdUYU8GehdT4C\", model=\"gpt-3.5-turbo\")\n",
"#training file will need to be updated with the id from the upload once complete"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|