diff --git a/sdk/openai/openai/assets.json b/sdk/openai/openai/assets.json index 53d7b0049f59..0fba4f5078f9 100644 --- a/sdk/openai/openai/assets.json +++ b/sdk/openai/openai/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "js", "TagPrefix": "js/openai/openai", - "Tag": "js/openai/openai_6b73e03317" + "Tag": "js/openai/openai_3df73efcf2" } diff --git a/sdk/openai/openai/review/openai.api.md b/sdk/openai/openai/review/openai.api.md index e6c1dcce4230..47152130509c 100644 --- a/sdk/openai/openai/review/openai.api.md +++ b/sdk/openai/openai/review/openai.api.md @@ -219,6 +219,7 @@ export interface ChatCompletions { export interface ChatCompletionsFunctionToolCall { function: FunctionCall; id: string; + index?: number; type: "function"; } diff --git a/sdk/openai/openai/sources/customizations/models/models.ts b/sdk/openai/openai/sources/customizations/models/models.ts index 40539b195492..4381b9a33d23 100644 --- a/sdk/openai/openai/sources/customizations/models/models.ts +++ b/sdk/openai/openai/sources/customizations/models/models.ts @@ -287,6 +287,8 @@ export interface ChatCompletionsFunctionToolCall { function: FunctionCall; /** The ID of the tool call. */ id: string; + /** The index of the tool call. */ + index?: number; } /** diff --git a/sdk/openai/openai/src/models/models.ts b/sdk/openai/openai/src/models/models.ts index adcbd83dcfbb..647feb0ec7f7 100644 --- a/sdk/openai/openai/src/models/models.ts +++ b/sdk/openai/openai/src/models/models.ts @@ -490,6 +490,8 @@ export interface ChatCompletionsFunctionToolCall { function: FunctionCall; /** The ID of the tool call. */ id: string; + /** The index of the tool call. */ + index?: number; } /** diff --git a/sdk/openai/openai/test/public/completions.spec.ts b/sdk/openai/openai/test/public/completions.spec.ts index cbef93243cf7..963af5a7d3e7 100644 --- a/sdk/openai/openai/test/public/completions.spec.ts +++ b/sdk/openai/openai/test/public/completions.spec.ts @@ -514,6 +514,40 @@ describe("OpenAI", function () { ); }); + it("calls toolCalls", async function () { + updateWithSucceeded( + await withDeployments( + getSucceeded( + authMethod, + deployments, + models, + chatCompletionDeployments, + chatCompletionModels, + ), + async (deploymentName) => + bufferAsyncIterable( + await client.streamChatCompletions( + deploymentName, + [{ role: "user", content: "What's the weather like in Boston?" }], + { + tools: [{ type: "function", function: getCurrentWeather }], + }, + ), + ), + (res) => + assertChatCompletionsList(res, { + functions: true, + // The API returns an empty choice in the first event for some + // reason. This should be fixed in the API. + allowEmptyChoices: true, + }), + ), + chatCompletionDeployments, + chatCompletionModels, + authMethod, + ); + }); + it("bring your own data", async function () { if (authMethod === "OpenAIKey") { this.skip(); diff --git a/sdk/openai/openai/test/public/utils/asserts.ts b/sdk/openai/openai/test/public/utils/asserts.ts index fe242cfd8bc0..4820838c2c18 100644 --- a/sdk/openai/openai/test/public/utils/asserts.ts +++ b/sdk/openai/openai/test/public/utils/asserts.ts @@ -180,6 +180,7 @@ function assertToolCall( ): void { assertIf(!stream, functionCall.type, assert.isString); assertIf(!stream, functionCall.id, assert.isString); + assertIf(Boolean(stream), functionCall.index, assert.isNumber); switch (functionCall.type) { case "function": assertFunctionCall(functionCall.function, { stream });