Skip to content

Commit

Permalink
fix(azure): include retry count header
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie authored and stainless-bot committed Jan 22, 2025
1 parent b7ab6bb commit 3e0ba40
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,10 @@ export class AzureOpenAI extends OpenAI {
this._deployment = deployment;
}

override buildRequest(options: Core.FinalRequestOptions<unknown>): {
override buildRequest(
options: Core.FinalRequestOptions<unknown>,
props: { retryCount?: number } = {},
): {
req: RequestInit;
url: string;
timeout: number;
Expand All @@ -591,7 +594,7 @@ export class AzureOpenAI extends OpenAI {
options.path = `/deployments/${model}${options.path}`;
}
}
return super.buildRequest(options);
return super.buildRequest(options, props);
}

private async _getAzureADToken(): Promise<string | undefined> {
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/azure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ describe('instantiate azure client', () => {
});
expect(req.headers as Headers).not.toHaveProperty('x-my-default-header');
});

test('includes retry count', () => {
const { req } = client.buildRequest(
{
path: '/foo',
method: 'post',
headers: { 'X-My-Default-Header': null },
},
{ retryCount: 1 },
);
expect((req.headers as Headers)['x-stainless-retry-count']).toEqual('1');
});
});

describe('defaultQuery', () => {
Expand Down

0 comments on commit 3e0ba40

Please sign in to comment.