|
7 | 7 | use OpenAI\Responses\Moderations\CreateResponseResult;
|
8 | 8 | use OpenAI\ValueObjects\Transporter\Response;
|
9 | 9 |
|
10 |
| -test('create', closure: function () { |
| 10 | +test('create legacy', closure: function () { |
11 | 11 | $client = mockClient('POST', 'moderations', [
|
12 | 12 | 'model' => 'text-moderation-latest',
|
13 | 13 | 'input' => 'I want to kill them.',
|
|
43 | 43 | expect($result->meta())
|
44 | 44 | ->toBeInstanceOf(MetaInformation::class);
|
45 | 45 | });
|
| 46 | + |
| 47 | +test('create omni', closure: function () { |
| 48 | + $client = mockClient('POST', 'moderations', [ |
| 49 | + 'model' => 'omni-moderation-latest', |
| 50 | + 'input' => 'I want to kill them.', |
| 51 | + ], Response::from(moderationOmniResource(), metaHeaders())); |
| 52 | + |
| 53 | + $result = $client->moderations()->create([ |
| 54 | + 'model' => 'omni-moderation-latest', |
| 55 | + 'input' => 'I want to kill them.', |
| 56 | + ]); |
| 57 | + |
| 58 | + expect($result) |
| 59 | + ->toBeInstanceOf(CreateResponse::class) |
| 60 | + ->id->toBe('modr-5MWoLO') |
| 61 | + ->model->toBe('omni-moderation-001') |
| 62 | + ->results->toBeArray()->toHaveCount(1) |
| 63 | + ->results->each->toBeInstanceOf(CreateResponseResult::class); |
| 64 | + |
| 65 | + expect($result->results[0]) |
| 66 | + ->flagged->toBeTrue() |
| 67 | + ->categories->toHaveCount(13) |
| 68 | + ->each->toBeInstanceOf(CreateResponseCategory::class); |
| 69 | + |
| 70 | + expect($result->results[0]->categories[Category::Illicit->value]) |
| 71 | + ->category->toBe(Category::Illicit) |
| 72 | + ->violated->toBe(false) |
| 73 | + ->score->toBe(0.1602763684674149); |
| 74 | + |
| 75 | + expect($result->results[0]->categories[Category::IllicitViolent->value]) |
| 76 | + ->category->toBe(Category::IllicitViolent) |
| 77 | + ->violated->toBe(true) |
| 78 | + ->score->toBe(0.9223177433013916); |
| 79 | + |
| 80 | + expect($result->meta()) |
| 81 | + ->toBeInstanceOf(MetaInformation::class); |
| 82 | +}); |
0 commit comments