Skip to content

Commit 08c66e8

Browse files
feat(api): Integrate fine_tuning.list_metrics from stainless
1 parent 574e8ba commit 08c66e8

7 files changed

Lines changed: 90 additions & 3 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 75
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai/togetherai-14a2d0f040bf287858da867ea3528581fb012d790d7e65b70f2b87f407efc7c7.yml
1+
configured_endpoints: 76
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai/togetherai-5f05c9669c67c3f4b0ebfe2317d2768cd96317424965ebb2acf06a7757a7d0ca.yml
33
openapi_spec_hash: 84f45151f4d0eed68551b5ffda61595a
4-
config_hash: 6c214c91fad5ead4849be777fd9e8108
4+
config_hash: ec427df08d61d8888138f15cd53c6454

MIGRATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ This affects the following methods:
6969

7070
- `client.beta.jig.retrieveLogs()`
7171
- `client.fineTuning.delete()`
72+
- `client.fineTuning.listMetrics()`
7273
- `client.models.list()`
7374
- `client.endpoints.list()`
7475
- `client.endpoints.listHardware()`

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ Types:
182182
- <code><a href="./src/resources/fine-tuning.ts">FineTuningEstimatePriceResponse</a></code>
183183
- <code><a href="./src/resources/fine-tuning.ts">FineTuningListCheckpointsResponse</a></code>
184184
- <code><a href="./src/resources/fine-tuning.ts">FineTuningListEventsResponse</a></code>
185+
- <code><a href="./src/resources/fine-tuning.ts">FineTuningListMetricsResponse</a></code>
185186

186187
Methods:
187188

@@ -194,6 +195,7 @@ Methods:
194195
- <code title="post /fine-tunes/estimate-price">client.fineTuning.<a href="./src/resources/fine-tuning.ts">estimatePrice</a>({ ...params }) -> FineTuningEstimatePriceResponse</code>
195196
- <code title="get /fine-tunes/{id}/checkpoints">client.fineTuning.<a href="./src/resources/fine-tuning.ts">listCheckpoints</a>(id) -> FineTuningListCheckpointsResponse</code>
196197
- <code title="get /fine-tunes/{id}/events">client.fineTuning.<a href="./src/resources/fine-tuning.ts">listEvents</a>(id) -> FineTuningListEventsResponse</code>
198+
- <code title="get /fine-tunes/{id}/metrics">client.fineTuning.<a href="./src/resources/fine-tuning.ts">listMetrics</a>(id, { ...params }) -> FineTuningListMetricsResponse</code>
197199

198200
# CodeInterpreter
199201

src/client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ import {
7070
FineTuningEstimatePriceResponse,
7171
FineTuningListCheckpointsResponse,
7272
FineTuningListEventsResponse,
73+
FineTuningListMetricsParams,
74+
FineTuningListMetricsResponse,
7375
FineTuningListResponse,
7476
FinetuneEvent,
7577
FinetuneEventType,
@@ -886,10 +888,12 @@ export declare namespace Together {
886888
type FineTuningEstimatePriceResponse as FineTuningEstimatePriceResponse,
887889
type FineTuningListCheckpointsResponse as FineTuningListCheckpointsResponse,
888890
type FineTuningListEventsResponse as FineTuningListEventsResponse,
891+
type FineTuningListMetricsResponse as FineTuningListMetricsResponse,
889892
type FineTuningCreateParams as FineTuningCreateParams,
890893
type FineTuningDeleteParams as FineTuningDeleteParams,
891894
type FineTuningContentParams as FineTuningContentParams,
892895
type FineTuningEstimatePriceParams as FineTuningEstimatePriceParams,
896+
type FineTuningListMetricsParams as FineTuningListMetricsParams,
893897
};
894898

895899
export {

src/resources/fine-tuning.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,23 @@ export class FineTuning extends APIResource {
144144
listEvents(id: string, options?: RequestOptions): APIPromise<FineTuningListEventsResponse> {
145145
return this._client.get(path`/fine-tunes/${id}/events`, options);
146146
}
147+
148+
/**
149+
* Retrieves recorded training metrics for a fine-tuning job in chronological
150+
* order. All query parameters are optional: omit them to retrieve all metrics.
151+
*
152+
* @example
153+
* ```ts
154+
* const response = await client.fineTuning.listMetrics('id');
155+
* ```
156+
*/
157+
listMetrics(
158+
id: string,
159+
query: FineTuningListMetricsParams | null | undefined = {},
160+
options?: RequestOptions,
161+
): APIPromise<FineTuningListMetricsResponse> {
162+
return this._client.get(path`/fine-tunes/${id}/metrics`, { query, ...options });
163+
}
147164
}
148165

149166
export interface FinetuneEvent {
@@ -1269,6 +1286,10 @@ export interface FineTuningListEventsResponse {
12691286
data: Array<FinetuneEvent>;
12701287
}
12711288

1289+
export interface FineTuningListMetricsResponse {
1290+
metrics?: Array<{ [key: string]: number }>;
1291+
}
1292+
12721293
export interface FineTuningCreateParams {
12731294
/**
12741295
* Name of the base model to run fine-tune job on
@@ -1646,6 +1667,33 @@ export namespace FineTuningEstimatePriceParams {
16461667
}
16471668
}
16481669

1670+
export interface FineTuningListMetricsParams {
1671+
/**
1672+
* Return only metrics with global_step >= this value.
1673+
*/
1674+
global_step_from?: number;
1675+
1676+
/**
1677+
* Return only metrics with global_step <= this value.
1678+
*/
1679+
global_step_to?: number;
1680+
1681+
/**
1682+
* Return only metrics logged at or after this ISO-8601 timestamp.
1683+
*/
1684+
logged_at_from?: string;
1685+
1686+
/**
1687+
* Return only metrics logged at or before this ISO-8601 timestamp.
1688+
*/
1689+
logged_at_to?: string;
1690+
1691+
/**
1692+
* Number of (uniformly sampled) train metrics to return.
1693+
*/
1694+
resolution?: number;
1695+
}
1696+
16491697
export declare namespace FineTuning {
16501698
export {
16511699
type FinetuneEvent as FinetuneEvent,
@@ -1658,9 +1706,11 @@ export declare namespace FineTuning {
16581706
type FineTuningEstimatePriceResponse as FineTuningEstimatePriceResponse,
16591707
type FineTuningListCheckpointsResponse as FineTuningListCheckpointsResponse,
16601708
type FineTuningListEventsResponse as FineTuningListEventsResponse,
1709+
type FineTuningListMetricsResponse as FineTuningListMetricsResponse,
16611710
type FineTuningCreateParams as FineTuningCreateParams,
16621711
type FineTuningDeleteParams as FineTuningDeleteParams,
16631712
type FineTuningContentParams as FineTuningContentParams,
16641713
type FineTuningEstimatePriceParams as FineTuningEstimatePriceParams,
1714+
type FineTuningListMetricsParams as FineTuningListMetricsParams,
16651715
};
16661716
}

src/resources/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ export {
6868
type FineTuningEstimatePriceResponse,
6969
type FineTuningListCheckpointsResponse,
7070
type FineTuningListEventsResponse,
71+
type FineTuningListMetricsResponse,
7172
type FineTuningCreateParams,
7273
type FineTuningDeleteParams,
7374
type FineTuningContentParams,
7475
type FineTuningEstimatePriceParams,
76+
type FineTuningListMetricsParams,
7577
} from './fine-tuning';
7678
export {
7779
Images,

tests/api-resources/fine-tuning.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,32 @@ describe('resource fineTuning', () => {
162162
expect(dataAndResponse.data).toBe(response);
163163
expect(dataAndResponse.response).toBe(rawResponse);
164164
});
165+
166+
test('listMetrics', async () => {
167+
const responsePromise = client.fineTuning.listMetrics('id');
168+
const rawResponse = await responsePromise.asResponse();
169+
expect(rawResponse).toBeInstanceOf(Response);
170+
const response = await responsePromise;
171+
expect(response).not.toBeInstanceOf(Response);
172+
const dataAndResponse = await responsePromise.withResponse();
173+
expect(dataAndResponse.data).toBe(response);
174+
expect(dataAndResponse.response).toBe(rawResponse);
175+
});
176+
177+
test('listMetrics: request options and params are passed correctly', async () => {
178+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
179+
await expect(
180+
client.fineTuning.listMetrics(
181+
'id',
182+
{
183+
global_step_from: 0,
184+
global_step_to: 0,
185+
logged_at_from: '2019-12-27T18:11:19.117Z',
186+
logged_at_to: '2019-12-27T18:11:19.117Z',
187+
resolution: 0,
188+
},
189+
{ path: '/_stainless_unknown_path' },
190+
),
191+
).rejects.toThrow(Together.NotFoundError);
192+
});
165193
});

0 commit comments

Comments
 (0)