@@ -39,12 +39,10 @@ public function testCreateWithBasicProperties(): void
39
39
$ candidate = new Candidate (
40
40
$ message ,
41
41
FinishReasonEnum::stop (),
42
- 25
43
42
);
44
43
45
44
$ this ->assertSame ($ message , $ candidate ->getMessage ());
46
45
$ this ->assertEquals (FinishReasonEnum::stop (), $ candidate ->getFinishReason ());
47
- $ this ->assertEquals (25 , $ candidate ->getTokenCount ());
48
46
}
49
47
50
48
/**
@@ -58,7 +56,7 @@ public function testWithDifferentFinishReasons(FinishReasonEnum $finishReason):
58
56
{
59
57
$ message = new ModelMessage ([new MessagePart ('Response ' )]);
60
58
61
- $ candidate = new Candidate ($ message , $ finishReason, 10 );
59
+ $ candidate = new Candidate ($ message , $ finishReason );
62
60
63
61
$ this ->assertEquals ($ finishReason , $ candidate ->getFinishReason ());
64
62
}
@@ -103,13 +101,11 @@ public function testWithComplexMessage(): void
103
101
104
102
$ candidate = new Candidate (
105
103
$ message ,
106
- FinishReasonEnum::toolCalls (),
107
- 150
104
+ FinishReasonEnum::toolCalls ()
108
105
);
109
106
110
107
$ this ->assertCount (6 , $ candidate ->getMessage ()->getParts ());
111
108
$ this ->assertTrue ($ candidate ->getFinishReason ()->isToolCalls ());
112
- $ this ->assertEquals (150 , $ candidate ->getTokenCount ());
113
109
}
114
110
115
111
/**
@@ -119,7 +115,11 @@ public function testWithComplexMessage(): void
119
115
*/
120
116
public function testWithMessageContainingFiles (): void
121
117
{
122
- $ file = new File ('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVQI12P4DwABAQEAG7buVgAAAABJRU5ErkJggg== ' , 'image/png ' );
118
+ $ base64Data = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVQI12P4DwABAQEAG7buVgAAAABJRU5ErkJggg== ' ;
119
+ $ file = new File (
120
+ 'data:image/png;base64, ' . $ base64Data ,
121
+ 'image/png '
122
+ );
123
123
124
124
$ message = new ModelMessage ([
125
125
new MessagePart ('I \'ve generated the requested image: ' ),
@@ -130,7 +130,6 @@ public function testWithMessageContainingFiles(): void
130
130
$ candidate = new Candidate (
131
131
$ message ,
132
132
FinishReasonEnum::stop (),
133
- 85
134
133
);
135
134
136
135
$ parts = $ candidate ->getMessage ()->getParts ();
@@ -139,42 +138,6 @@ public function testWithMessageContainingFiles(): void
139
138
$ this ->assertEquals ('The image shows a flowchart of the process. ' , $ parts [2 ]->getText ());
140
139
}
141
140
142
- /**
143
- * Tests candidate with different token counts.
144
- *
145
- * @dataProvider tokenCountProvider
146
- * @param int $tokenCount
147
- * @return void
148
- */
149
- public function testWithDifferentTokenCounts (int $ tokenCount ): void
150
- {
151
- $ message = new ModelMessage ([new MessagePart ('Response ' )]);
152
-
153
- $ candidate = new Candidate (
154
- $ message ,
155
- FinishReasonEnum::stop (),
156
- $ tokenCount
157
- );
158
-
159
- $ this ->assertEquals ($ tokenCount , $ candidate ->getTokenCount ());
160
- }
161
-
162
- /**
163
- * Provides different token counts.
164
- *
165
- * @return array
166
- */
167
- public function tokenCountProvider (): array
168
- {
169
- return [
170
- 'zero ' => [0 ],
171
- 'small ' => [10 ],
172
- 'medium ' => [500 ],
173
- 'large ' => [4000 ],
174
- 'very_large ' => [100000 ],
175
- ];
176
- }
177
-
178
141
/**
179
142
* Tests candidate rejects non-model message.
180
143
*
@@ -191,8 +154,7 @@ public function testRejectsNonModelMessage(): void
191
154
192
155
new Candidate (
193
156
$ userMessage ,
194
- FinishReasonEnum::stop (),
195
- 10
157
+ FinishReasonEnum::stop ()
196
158
);
197
159
}
198
160
@@ -213,8 +175,7 @@ public function testRejectsMessageWithDifferentRole(): void
213
175
214
176
new Candidate (
215
177
$ message ,
216
- FinishReasonEnum::stop (),
217
- 10
178
+ FinishReasonEnum::stop ()
218
179
);
219
180
}
220
181
@@ -234,7 +195,6 @@ public function testJsonSchema(): void
234
195
$ this ->assertArrayHasKey ('properties ' , $ schema );
235
196
$ this ->assertArrayHasKey (Candidate::KEY_MESSAGE , $ schema ['properties ' ]);
236
197
$ this ->assertArrayHasKey (Candidate::KEY_FINISH_REASON , $ schema ['properties ' ]);
237
- $ this ->assertArrayHasKey (Candidate::KEY_TOKEN_COUNT , $ schema ['properties ' ]);
238
198
239
199
// Check finishReason property
240
200
$ finishReasonSchema = $ schema ['properties ' ][Candidate::KEY_FINISH_REASON ];
@@ -246,13 +206,9 @@ public function testJsonSchema(): void
246
206
$ this ->assertContains ('tool_calls ' , $ finishReasonSchema ['enum ' ]);
247
207
$ this ->assertContains ('error ' , $ finishReasonSchema ['enum ' ]);
248
208
249
- // Check tokenCount property
250
- $ tokenCountSchema = $ schema ['properties ' ][Candidate::KEY_TOKEN_COUNT ];
251
- $ this ->assertEquals ('integer ' , $ tokenCountSchema ['type ' ]);
252
-
253
209
// Check required fields
254
210
$ this ->assertArrayHasKey ('required ' , $ schema );
255
- $ this ->assertEquals ([Candidate::KEY_MESSAGE , Candidate::KEY_FINISH_REASON , Candidate:: KEY_TOKEN_COUNT ], $ schema ['required ' ]);
211
+ $ this ->assertEquals ([Candidate::KEY_MESSAGE , Candidate::KEY_FINISH_REASON ], $ schema ['required ' ]);
256
212
}
257
213
258
214
/**
@@ -266,12 +222,10 @@ public function testWithEmptyMessageParts(): void
266
222
267
223
$ candidate = new Candidate (
268
224
$ message ,
269
- FinishReasonEnum::stop (),
270
- 0
225
+ FinishReasonEnum::stop ()
271
226
);
272
227
273
228
$ this ->assertCount (0 , $ candidate ->getMessage ()->getParts ());
274
- $ this ->assertEquals (0 , $ candidate ->getTokenCount ());
275
229
}
276
230
277
231
/**
@@ -287,12 +241,10 @@ public function testWithMaxLengthFinishReason(): void
287
241
288
242
$ candidate = new Candidate (
289
243
$ message ,
290
- FinishReasonEnum::length (),
291
- 4096
244
+ FinishReasonEnum::length ()
292
245
);
293
246
294
247
$ this ->assertTrue ($ candidate ->getFinishReason ()->isLength ());
295
- $ this ->assertEquals (4096 , $ candidate ->getTokenCount ());
296
248
}
297
249
298
250
/**
@@ -308,8 +260,7 @@ public function testWithContentFilterFinishReason(): void
308
260
309
261
$ candidate = new Candidate (
310
262
$ message ,
311
- FinishReasonEnum::contentFilter (),
312
- 8
263
+ FinishReasonEnum::contentFilter ()
313
264
);
314
265
315
266
$ this ->assertTrue ($ candidate ->getFinishReason ()->isContentFilter ());
@@ -328,8 +279,7 @@ public function testWithErrorFinishReason(): void
328
279
329
280
$ candidate = new Candidate (
330
281
$ message ,
331
- FinishReasonEnum::error (),
332
- 9
282
+ FinishReasonEnum::error ()
333
283
);
334
284
335
285
$ this ->assertTrue ($ candidate ->getFinishReason ()->isError ());
@@ -349,16 +299,14 @@ public function testToArray(): void
349
299
350
300
$ candidate = new Candidate (
351
301
$ message ,
352
- FinishReasonEnum::stop (),
353
- 45
302
+ FinishReasonEnum::stop ()
354
303
);
355
304
356
305
$ json = $ this ->assertToArrayReturnsArray ($ candidate );
357
306
358
- $ this ->assertArrayHasKeys ($ json , [Candidate::KEY_MESSAGE , Candidate::KEY_FINISH_REASON , Candidate:: KEY_TOKEN_COUNT ]);
307
+ $ this ->assertArrayHasKeys ($ json , [Candidate::KEY_MESSAGE , Candidate::KEY_FINISH_REASON ]);
359
308
$ this ->assertIsArray ($ json [Candidate::KEY_MESSAGE ]);
360
309
$ this ->assertEquals (FinishReasonEnum::stop ()->value , $ json [Candidate::KEY_FINISH_REASON ]);
361
- $ this ->assertEquals (45 , $ json [Candidate::KEY_TOKEN_COUNT ]);
362
310
}
363
311
364
312
/**
@@ -372,19 +320,23 @@ public function testFromArray(): void
372
320
Candidate::KEY_MESSAGE => [
373
321
Message::KEY_ROLE => MessageRoleEnum::model ()->value ,
374
322
Message::KEY_PARTS => [
375
- [MessagePart::KEY_TYPE => MessagePartTypeEnum::text ()->value , MessagePart::KEY_TEXT => 'Response text 1 ' ],
376
- [MessagePart::KEY_TYPE => MessagePartTypeEnum::text ()->value , MessagePart::KEY_TEXT => 'Response text 2 ' ]
323
+ [
324
+ MessagePart::KEY_TYPE => MessagePartTypeEnum::text ()->value ,
325
+ MessagePart::KEY_TEXT => 'Response text 1 '
326
+ ],
327
+ [
328
+ MessagePart::KEY_TYPE => MessagePartTypeEnum::text ()->value ,
329
+ MessagePart::KEY_TEXT => 'Response text 2 '
330
+ ]
377
331
]
378
332
],
379
333
Candidate::KEY_FINISH_REASON => FinishReasonEnum::stop ()->value ,
380
- Candidate::KEY_TOKEN_COUNT => 75
381
334
];
382
335
383
336
$ candidate = Candidate::fromArray ($ json );
384
337
385
338
$ this ->assertInstanceOf (Candidate::class, $ candidate );
386
339
$ this ->assertEquals (FinishReasonEnum::stop (), $ candidate ->getFinishReason ());
387
- $ this ->assertEquals (75 , $ candidate ->getTokenCount ());
388
340
$ this ->assertCount (2 , $ candidate ->getMessage ()->getParts ());
389
341
$ this ->assertEquals ('Response text 1 ' , $ candidate ->getMessage ()->getParts ()[0 ]->getText ());
390
342
$ this ->assertEquals ('Response text 2 ' , $ candidate ->getMessage ()->getParts ()[1 ]->getText ());
@@ -403,12 +355,10 @@ public function testArrayRoundTrip(): void
403
355
new MessagePart ('Generated response ' ),
404
356
new MessagePart (new FunctionCall ('call_123 ' , 'search ' , ['q ' => 'test ' ]))
405
357
]),
406
- FinishReasonEnum::toolCalls (),
407
- 120
358
+ FinishReasonEnum::toolCalls ()
408
359
),
409
360
function ($ original , $ restored ) {
410
361
$ this ->assertEquals ($ original ->getFinishReason ()->value , $ restored ->getFinishReason ()->value );
411
- $ this ->assertEquals ($ original ->getTokenCount (), $ restored ->getTokenCount ());
412
362
$ this ->assertCount (
413
363
count ($ original ->getMessage ()->getParts ()),
414
364
$ restored ->getMessage ()->getParts ()
@@ -434,8 +384,7 @@ public function testImplementsWithArrayTransformationInterface(): void
434
384
{
435
385
$ candidate = new Candidate (
436
386
new ModelMessage ([new MessagePart ('test ' )]),
437
- FinishReasonEnum::stop (),
438
- 10
387
+ FinishReasonEnum::stop ()
439
388
);
440
389
$ this ->assertImplementsArrayTransformation ($ candidate );
441
390
}
0 commit comments