@@ -62,6 +62,7 @@ def system_prompt():
62
62
@pytest .mark .parametrize (
63
63
"content, exp_result" ,
64
64
[
65
+ # Case 1: Image
65
66
(
66
67
{
67
68
"image" : {
@@ -78,10 +79,12 @@ def system_prompt():
78
79
"type" : "image_url" ,
79
80
},
80
81
),
82
+ # Case 2: Text
81
83
(
82
84
{"text" : "hello" },
83
85
{"type" : "text" , "text" : "hello" },
84
86
),
87
+ # Case 3: Other
85
88
(
86
89
{"other" : {"a" : 1 }},
87
90
{
@@ -243,10 +246,12 @@ def test_format_request(model, messages, tool_specs, system_prompt):
243
246
@pytest
8000
.mark .parametrize (
244
247
("event" , "exp_chunk" ),
245
248
[
249
+ # Case 1: Message start
246
250
(
247
251
{"chunk_type" : "message_start" },
248
252
{"messageStart" : {"role" : "assistant" }},
249
253
),
254
+ # Case 2: Content Start - Tool Use
250
255
(
251
256
{
252
257
"chunk_type" : "content_start" ,
@@ -255,10 +260,12 @@ def test_format_request(model, messages, tool_specs, system_prompt):
255
260
},
256
261
{"contentBlockStart" : {"start" : {"toolUse" : {"name" : "calculator" , "toolUseId" : "c1" }}}},
257
262
),
263
+ # Case 3: Content Start - Text
258
264
(
259
265
{"chunk_type" : "content_start" , "data_type" : "text" },
260
266
{"contentBlockStart" : {"start" : {}}},
261
267
),
268
+ # Case 4: Content Delta - Tool Use
262
269
(
263
270
{
264
271
"chunk_type" : "content_delta" ,
@@ -267,26 +274,32 @@ def test_format_request(model, messages, tool_specs, system_prompt):
267
274
},
268
275
{"contentBlockDelta" : {"delta" : {"toolUse" : {"input" : '{"expression": "2+2"}' }}}},
269
276
),
277
+ # Case 5: Content Delta - Text
270
278
(
271
279
{"chunk_type" : "content_delta" , "data_type" : "text" , "data" : "hello" },
272
280
{"contentBlockDelta" : {"delta" : {"text" : "hello" }}},
273
281
),
282
+ # Case 6: Content Stop
274
283
(
275
284
{"chunk_type" : "content_stop" },
276
285
{"contentBlockStop" : {}},
277
286
),
287
+ # Case 7: Message Stop - Tool Use
278
288
(
279
289
{"chunk_type" : "message_stop" , "data" : "tool_calls" },
280
290
{"messageStop" : {"stopReason" : "tool_use" }},
281
291
),
292
+ # Case 8: Message Stop - Max Tokens
282
293
(
283
294
{"chunk_type" : "message_stop" , "data" : "length" },
284
295
{"messageStop" : {"stopReason" : "max_tokens" }},
285
296
),
297
+ # Case 9: Message Stop - End Turn
286
298
(
287
299
{"chunk_type" : "message_stop" , "data" : "stop" },
288
300
{"messageStop" : {"stopReason" : "end_turn" }},
289
301
),
302
+ # Case 10: Metadata
290
303
(
291
304
{
292
305
"chunk_type" : "metadata" ,
0 commit comments