Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/openai/openai/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions sdk/openai/openai/review/openai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export interface ChatCompletions {
export interface ChatCompletionsFunctionToolCall {
function: FunctionCall;
id: string;
index?: number;
type: "function";
}

Expand Down
2 changes: 2 additions & 0 deletions sdk/openai/openai/sources/customizations/models/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions sdk/openai/openai/src/models/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
34 changes: 34 additions & 0 deletions sdk/openai/openai/test/public/completions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions sdk/openai/openai/test/public/utils/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down