Skip to content

Commit 8faafcd

Browse files
committed
update make_any_request in server test utils
1 parent abdb499 commit 8faafcd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/server/tests/utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,12 @@ def make_any_request(
308308
stream = data.get('stream', False)
309309
if stream:
310310
content: list[str] = []
311+
reasoning_content: list[str] = []
311312
tool_calls: list[dict] = []
312313
finish_reason: Optional[str] = None
313314

314315
content_parts = 0
316+
reasoning_content_parts = 0
315317
tool_call_parts = 0
316318
arguments_parts = 0
317319

@@ -322,6 +324,10 @@ def make_any_request(
322324
assert len(choice['delta']['content']) > 0, f'Expected non empty content delta!'
323325
content.append(choice['delta']['content'])
324326
content_parts += 1
327+
if choice['delta'].get('reasoning_content') is not None:
328+
assert len(choice['delta']['reasoning_content']) > 0, f'Expected non empty reasoning_content delta!'
329+
reasoning_content.append(choice['delta']['reasoning_content'])
330+
reasoning_content_parts += 1
325331
if choice['delta'].get('finish_reason') is not None:
326332
finish_reason = choice['delta']['finish_reason']
327333
for tc in choice['delta'].get('tool_calls', []):
@@ -349,8 +355,10 @@ def make_any_request(
349355
tool_call['function']['name'] = tool_call['function'].get('name', '') + fct['name']
350356
if fct.get('arguments') is not None:
351357
tool_call['function']['arguments'] += fct['arguments']
358+
arguments_parts += 1
359+
tool_call_parts += 1
352360

353-
print(f'Streamed response had {content_parts} content parts, {tool_call_parts} tool call parts incl. {arguments_parts} arguments parts')
361+
print(f'Streamed response had {content_parts} content parts, {reasoning_content_parts} reasoning_content parts, {tool_call_parts} tool call parts incl. {arguments_parts} arguments parts')
354362
result = dict(
355363
choices=[
356364
dict(
@@ -359,6 +367,7 @@ def make_any_request(
359367
message=dict(
360368
role='assistant',
361369
content=''.join(content) if content else None,
370+
reasoning_content=''.join(reasoning_content) if reasoning_content else None,
362371
tool_calls=tool_calls if tool_calls else None,
363372
),
364373
)

0 commit comments

Comments
 (0)