■ OpenAI 클래스의 files 변수를 사용해 파일을 업로드하는 방법을 보여준다.
▶ main.py
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 |
import os from openai import OpenAI os.environ["OPENAI_API_KEY"] = "<OPENAI_API_KEY>" openAI = OpenAI() fileObject = openAI.files.create( file = open("tsukuyomi_prepared.jsonl", "rb"), purpose = "fine-tune" ) print(f"File ID : {fileObject.id}") """ FileObject( id = 'file-la32xWXKcIHXWpe8P4d8RVEJ', bytes = 70794, created_at = 1717680553, filename = 'tsukuyomi_prepared.jsonl', object = 'file', purpose = 'fine-tune', status = 'processed', status_details = None ) """ |
▶ requirements.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
annotated-types==0.7.0 anyio==4.4.0 certifi==2024.6.2 distro==1.9.0 exceptiongroup==1.2.1 h11==0.14.0 httpcore==1.0.5 httpx==0.27.0 idna==3.7 openai==1.31.1 pydantic==2.7.3 pydantic_core==2.18.4 sniffio==1.3.1 tqdm==4.66.4 typing_extensions==4.12.1 |