diff --git a/openiziai/fine_tuning.py b/openiziai/fine_tuning.py index 59d46ec..d8b4a0b 100644 --- a/openiziai/fine_tuning.py +++ b/openiziai/fine_tuning.py @@ -24,9 +24,9 @@ class JobStatus(Enum): class FineTuning(BaseModel): - client: OpenAI = Field(default=None, description='Client da OpenAI.') + client: OpenAI = Field(description='Client da OpenAI.') train_file: Path | str - task: Task = Field(default=None) + task: Task = Field() model: str = Field(default='gpt-3.5-turbo') _file_id: str = PrivateAttr(default=None) _job_id: str = PrivateAttr(default=None) diff --git a/openiziai/tools/train_data.py b/openiziai/tools/train_data.py index 21588f1..ac7ea9a 100644 --- a/openiziai/tools/train_data.py +++ b/openiziai/tools/train_data.py @@ -38,11 +38,9 @@ class TrainDataTool(BaseModel): client: OpenAI = Field(default=None, description='Client da OpenAI.') data: DataDict = Field( - default=None, description='Dados utilizados para construir o dado de treino.', ) task: Task = Field( - default=None, description='Descrição da task que o modelo deverá executar.', ) model: str = Field( diff --git a/tests/test_fine_tuning.py b/tests/test_fine_tuning.py index 47a4294..2ed74a0 100644 --- a/tests/test_fine_tuning.py +++ b/tests/test_fine_tuning.py @@ -7,25 +7,34 @@ from openiziai.fine_tuning import FineTuning -def test_size_validation_success(openai_fine_tuning): +def test_init_invalid_data(): + with pytest.raises(ValidationError): + FineTuning(client=None, task=None) + + +def test_size_validation_success(openai_fine_tuning, valid_task): mock_path = MagicMock(spec=Path) mock_path.stat.return_value.st_size = 100000 # Menos de 512MB - fine_tuning = FineTuning(client=openai_fine_tuning, train_file=mock_path) + fine_tuning = FineTuning( + client=openai_fine_tuning, task=valid_task, train_file=mock_path + ) assert fine_tuning.train_file == mock_path -def test_size_validation_failure(openai_fine_tuning): +def test_size_validation_failure(openai_fine_tuning, valid_task): mock_path = MagicMock(spec=Path) mock_path.stat.return_value.st_size = 600000000 with pytest.raises(ValidationError): - FineTuning(client=openai_fine_tuning, train_file=mock_path) + FineTuning( + client=openai_fine_tuning, task=valid_task, train_file=mock_path + ) def test_upload_file_to_openai(fine_tuning): - with patch('builtins.open', mock_open(read_data="data")): + with patch('builtins.open', mock_open(read_data='data')): fine_tuning.upload_file_to_openai() assert fine_tuning.file_id == 'file-id'