diff --git a/.stats.yml b/.stats.yml index 8659ab92..9ca0065e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 15 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2FTogetherAI-4365478ddf8533c4aeced4c0be4bde57b5930a13385c7500da6e4eb493b2cbcc.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2FTogetherAI-fe6fb14a0be4c133d8a105140bca7128149a2b762e763ad5e7c3b1e5909cc08b.yml diff --git a/src/core.ts b/src/core.ts index a437669e..ecb913d0 100644 --- a/src/core.ts +++ b/src/core.ts @@ -365,9 +365,13 @@ export abstract class APIClient { delete reqHeaders['content-type']; } - // Don't set the retry count header if it was already set or removed by the caller. We check `headers`, - // which can contain nulls, instead of `reqHeaders` to account for the removal case. - if (getHeader(headers, 'x-stainless-retry-count') === undefined) { + // Don't set the retry count header if it was already set or removed through default headers or by the + // caller. We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to + // account for the removal case. + if ( + getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined && + getHeader(headers, 'x-stainless-retry-count') === undefined + ) { reqHeaders['x-stainless-retry-count'] = String(retryCount); } diff --git a/src/resources/fine-tune.ts b/src/resources/fine-tune.ts index 32f408ee..765b353b 100644 --- a/src/resources/fine-tune.ts +++ b/src/resources/fine-tune.ts @@ -114,6 +114,8 @@ export interface FineTune { wandb_project_name?: string; wandb_url?: string; + + warmup_ratio?: number; } export namespace FineTune { @@ -308,6 +310,12 @@ export interface FineTuneCreateParams { * API key for Weights & Biases integration */ wandb_api_key?: string; + + /** + * The percent of steps at the start of training to linearly increase the + * learning-rate. + */ + warmup_ratio?: number; } export namespace FineTuneCreateParams { diff --git a/tests/api-resources/fine-tune.test.ts b/tests/api-resources/fine-tune.test.ts index 52e9e5bf..cdcfd5c2 100644 --- a/tests/api-resources/fine-tune.test.ts +++ b/tests/api-resources/fine-tune.test.ts @@ -33,6 +33,7 @@ describe('resource fineTune', () => { training_type: { type: 'Full' }, validation_file: 'validation_file', wandb_api_key: 'wandb_api_key', + warmup_ratio: 0, }); }); diff --git a/tests/index.test.ts b/tests/index.test.ts index f2d29191..2fa9714a 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -295,6 +295,39 @@ describe('retries', () => { expect(capturedRequest!.headers as Headers).not.toHaveProperty('x-stainless-retry-count'); }); + test('omit retry count header by default', async () => { + let count = 0; + let capturedRequest: RequestInit | undefined; + const testFetch = async (url: RequestInfo, init: RequestInit = {}): Promise => { + count++; + if (count <= 2) { + return new Response(undefined, { + status: 429, + headers: { + 'Retry-After': '0.1', + }, + }); + } + capturedRequest = init; + return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); + }; + const client = new Together({ + apiKey: 'My API Key', + fetch: testFetch, + maxRetries: 4, + defaultHeaders: { 'X-Stainless-Retry-Count': null }, + }); + + expect( + await client.request({ + path: '/foo', + method: 'get', + }), + ).toEqual({ a: 1 }); + + expect(capturedRequest!.headers as Headers).not.toHaveProperty('x-stainless-retry-count'); + }); + test('overwrite retry count header', async () => { let count = 0; let capturedRequest: RequestInit | undefined;