Skip to content

Commit f1eed1c

Browse files
tsuzaki430gr2m
andauthored
chore(azure) add built-in tools tests for azure provider Responses API (#9431)
## Background This pull request doesn't update any features to @ai-sdk/azure. However, it adds tests that will help ensure the soundness of future updates. I would like to add tests for when doStream and doGenerate are processed in the Responses API. In the tests for the Responses API in @ai-sdk/openai, it is possible to obtain idempotent results for doGenerate and doStream by passing the result data chunks to the function in advance. I would like to add similar tests for the Responses API in @ai-sdk/azure. ## Summary This pull request doesn't update any features to @ai-sdk/azure. I created the Azure test code by referring to the OpenAI test code. I copied some parts. - add `createModel` function for idempotent results for doGenerate and doStream. - add tool using test - add code interpreter test - add file search test - add image generation test ( doGenerate only because not supported stream on azure platform ) ## Manual Verification Since there were no functional changes, I confirmed that there was no change in the test results. - ai-core src/generate-text/azure-responses-code-interpreter.ts src/stream-text/azure-responses-code-interpreter.ts --------- Co-authored-by: tsuzaki430 <[email protected]> Co-authored-by: Gregor Martynus <[email protected]>
1 parent c1687b8 commit f1eed1c

10 files changed

+4718
-5
lines changed

.changeset/orange-peaches-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ai-sdk/azure': patch
3+
---
4+
5+
Support idempotent doGenerate/doStream with pre-supplied result chunks in Responses API tests.

packages/azure/src/__fixtures__/azure-code-interpreter-tool.1.chunks.txt

Lines changed: 341 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"id": "resp_02ffbc38ae6fca1a0068ec87605cfc819793efdf27e5496675",
3+
"object": "response",
4+
"created_at": 1760331616,
5+
"status": "completed",
6+
"background": false,
7+
"content_filters": null,
8+
"error": null,
9+
"incomplete_details": null,
10+
"instructions": null,
11+
"max_output_tokens": null,
12+
"max_tool_calls": null,
13+
"model": "gpt-5-mini",
14+
"output": [
15+
{
16+
"id": "rs_02ffbc38ae6fca1a0068ec8762f61881979bf5191564930c23",
17+
"type": "reasoning",
18+
"summary": []
19+
},
20+
{
21+
"id": "ci_02ffbc38ae6fca1a0068ec876654a08197af4d648fe8bba210",
22+
"type": "code_interpreter_call",
23+
"status": "completed",
24+
"code": "import random\n\n# Generate five random numbers between 1 and 100 with two decimal places\nnumbers = [round(random.uniform(1, 100), 2) for _ in range(5)]\n\n# Print the program and its execution results\nprint(\"Program: Generate five random numbers between 1 and 100 with two decimal places\")\nprint(\"Generated numbers:\")\nfor i, num in enumerate(numbers, start=1):\n print(f\"{i}: {num:.2f}\")",
25+
"container_id": "cntr_68ec87613e58819097ec47888dc686d8088a1d37157e7565",
26+
"outputs": [
27+
{
28+
"type": "logs",
29+
"logs": "Program: Generate five random numbers between 1 and 100 with two decimal places\nGenerated numbers:\n1: 74.07\n2: 94.14\n3: 53.74\n4: 77.29\n5: 87.68\n"
30+
}
31+
]
32+
},
33+
{
34+
"id": "msg_02ffbc38ae6fca1a0068ec8768f35c81979428e19fa11468f1",
35+
"type": "message",
36+
"status": "completed",
37+
"content": [
38+
{
39+
"type": "output_text",
40+
"annotations": [],
41+
"logprobs": [],
42+
"text": "I ran the program and produced five random numbers between 1 and 100 with two decimal places. Results shown above:\n\n1: 74.07\n2: 94.14\n3: 53.74\n4: 77.29\n5: 87.68\n\nIf you want the code to be saved to a file, run multiple sets, or use a fixed seed for reproducible results, tell me and I can adjust."
43+
}
44+
],
45+
"role": "assistant"
46+
}
47+
],
48+
"parallel_tool_calls": true,
49+
"previous_response_id": null,
50+
"prompt_cache_key": null,
51+
"reasoning": {
52+
"effort": "medium",
53+
"summary": null
54+
},
55+
"safety_identifier": null,
56+
"service_tier": "default",
57+
"store": true,
58+
"temperature": 1,
59+
"text": {
60+
"format": {
61+
"type": "text"
62+
},
63+
"verbosity": "medium"
64+
},
65+
"tool_choice": "auto",
66+
"tools": [
67+
{
68+
"type": "code_interpreter",
69+
"container": {
70+
"type": "auto"
71+
}
72+
}
73+
],
74+
"top_logprobs": 0,
75+
"top_p": 1,
76+
"truncation": "disabled",
77+
"usage": {
78+
"input_tokens": 1750,
79+
"input_tokens_details": {
80+
"cached_tokens": 0
81+
},
82+
"output_tokens": 400,
83+
"output_tokens_details": {
84+
"reasoning_tokens": 192
85+
},
86+
"total_tokens": 2150
87+
},
88+
"user": null,
89+
"metadata": {}
90+
}

packages/azure/src/__fixtures__/openai-file-search-tool.1.chunks.txt

Lines changed: 94 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"id": "resp_0a098396a8feca410068caae39e7648196b346e99fa8ec494c",
3+
"object": "response",
4+
"created_at": 1758113338,
5+
"status": "completed",
6+
"background": false,
7+
"error": null,
8+
"incomplete_details": null,
9+
"instructions": null,
10+
"max_output_tokens": null,
11+
"max_tool_calls": null,
12+
"model": "gpt-5-mini-2025-08-07",
13+
"output": [
14+
{
15+
"id": "rs_0a098396a8feca410068caae3b47208196957fe59419daad70",
16+
"type": "reasoning",
17+
"summary": []
18+
},
19+
{
20+
"id": "fs_0a098396a8feca410068caae3cab5c8196a54fd00498464e62",
21+
"type": "file_search_call",
22+
"status": "completed",
23+
"queries": [
24+
"What is an embedding model according to this document?",
25+
"What is an embedding model?",
26+
"definition of embedding model in the document",
27+
"embedding model description"
28+
],
29+
"results": null
30+
},
31+
{
32+
"id": "rs_0a098396a8feca410068caae3e21a081968e7ac588401c4a6a",
33+
"type": "reasoning",
34+
"summary": []
35+
},
36+
{
37+
"id": "msg_0a098396a8feca410068caae457c508196b2fcd079d1d3ec74",
38+
"type": "message",
39+
"status": "completed",
40+
"content": [
41+
{
42+
"type": "output_text",
43+
"annotations": [
44+
{
45+
"type": "file_citation",
46+
"file_id": "file-Ebzhf8H4DPGPr9pUhr7n7v",
47+
"filename": "ai.pdf",
48+
"index": 438
49+
}
50+
],
51+
"logprobs": [],
52+
"text": "According to the document, an embedding model is used to convert complex data (like words or images) into a dense vector (a list of numbers) representation called an embedding, which captures semantic and syntactic relationships. Unlike generative models, embedding models do not generate new text or data; instead, they provide these vector representations to be used as input for other models or other natural language processing tasks ."
53+
}
54+
],
55+
"role": "assistant"
56+
}
57+
],
58+
"parallel_tool_calls": true,
59+
"previous_response_id": null,
60+
"prompt_cache_key": null,
61+
"reasoning": { "effort": "medium", "summary": null },
62+
"safety_identifier": null,
63+
"service_tier": "default",
64+
"store": true,
65+
"temperature": 1,
66+
"text": { "format": { "type": "text" }, "verbosity": "medium" },
67+
"tool_choice": "auto",
68+
"tools": [
69+
{
70+
"type": "file_search",
71+
"filters": null,
72+
"max_num_results": 20,
73+
"ranking_options": { "ranker": "auto", "score_threshold": 0 },
74+
"vector_store_ids": ["vs_68caad8bd5d88191ab766cf043d89a18"]
75+
}
76+
],
77+
"top_logprobs": 0,
78+
"top_p": 1,
79+
"truncation": "disabled",
80+
"usage": {
81+
"input_tokens": 3700,
82+
"input_tokens_details": { "cached_tokens": 2560 },
83+
"output_tokens": 741,
84+
"output_tokens_details": { "reasoning_tokens": 640 },
85+
"total_tokens": 4441
86+
},
87+
"user": null,
88+
"metadata": {}
89+
}

0 commit comments

Comments
 (0)