Skip to content

Commit 61f8b5a

Browse files
committed
Readme updated.
1 parent e2d1552 commit 61f8b5a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@ FineTuner::fineTune(string $fileId, string $model = 'gpt-3.5-turbo'): string
4545
```php
4646
use HalilCosdu\FineTuner\Facades\FineTuner;
4747

48-
FineTuner::generateExamples("A versatile AI assistant designed to provide personalized support across all aspects of life, from physical health and mental wellness to emotional well-being, adapting its guidance to the user's unique situation and needs. It offers practical advice, empathetic support, and proactive reminders, all while ensuring privacy and security, and continuously evolving through feedback and research.")
48+
// Generate examples for fine-tuning
49+
$trainingExamples = FineTuner::generateExamples("A versatile AI assistant designed to provide personalized support across all aspects of life, from physical health and mental wellness to emotional well-being, adapting its guidance to the user's unique situation and needs. It offers practical advice, empathetic support, and proactive reminders, all while ensuring privacy and security, and continuously evolving through feedback and research.")
50+
51+
// If the `FINE_TUNER_USE_STORAGE` environment variable is set to `true`, the `file_url` will be returned for the upload function. Alternatively, you can create your own training `.jsonl` file using the `training_data`.
52+
53+
// Upload the training data
54+
$fileId = FineTuner::upload($trainingExamples['file_url'])
55+
56+
// Fine-tune the model
57+
FineTuner::fineTune($fileId, 'gpt-3.5-turbo')
4958
```
5059

5160
## Testing

src/FineTuner.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use OpenAI as OpenAIFactory;
88
use OpenAI\Client;
99

10-
class FineTuner
10+
readonly class FineTuner
1111
{
1212
public Client $client;
1313

@@ -98,11 +98,14 @@ private function saveTrainingExamples($prevExamples, $systemMessage): array
9898
}
9999
}
100100

101+
$url = null;
102+
101103
if (config('finetuner.use_storage')) {
102104
Storage::disk(config('finetuner.storage.disk'))->put('training_data.jsonl', json_encode($trainingExamples));
105+
$url = Storage::disk(config('finetuner.storage.disk'))->url('training_data.jsonl');
103106
}
104107

105-
return $trainingExamples;
108+
return ['training_data' => $trainingExamples, 'file_url' => $url];
106109
}
107110

108111
public function upload(string $file): string

0 commit comments

Comments
 (0)