Skip to content

Commit a80e30e

Browse files
feat(api): manual updates
Move models to platform api
1 parent b10da1f commit a80e30e

File tree

6 files changed

+60
-52
lines changed

6 files changed

+60
-52
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 77
1+
configured_endpoints: 76
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/digitalocean%2Fgradientai-e8b3cbc80e18e4f7f277010349f25e1319156704f359911dc464cc21a0d077a6.yml
33
openapi_spec_hash: c773d792724f5647ae25a5ae4ccec208
4-
config_hash: 94c621a4008714c6ab5f773670265bcc
4+
config_hash: f0976fbc552ea878bb527447b5e663c9

api.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,8 @@ Types:
367367
- <code><a href="./src/resources/models.ts">APIAgreement</a></code>
368368
- <code><a href="./src/resources/models.ts">APIModel</a></code>
369369
- <code><a href="./src/resources/models.ts">APIModelVersion</a></code>
370-
- <code><a href="./src/resources/models.ts">Model</a></code>
371370
- <code><a href="./src/resources/models.ts">ModelListResponse</a></code>
372371

373372
Methods:
374373

375-
- <code title="get /models/{model}">client.models.<a href="./src/resources/models.ts">retrieve</a>(model) -> Model</code>
376-
- <code title="get /models">client.models.<a href="./src/resources/models.ts">list</a>() -> ModelListResponse</code>
374+
- <code title="get /v2/gen-ai/models">client.models.<a href="./src/resources/models.ts">list</a>({ ...params }) -> ModelListResponse</code>

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
APIAgreement,
2222
APIModel,
2323
APIModelVersion,
24-
Model,
24+
ModelListParams,
2525
ModelListResponse,
2626
Models,
2727
} from './resources/models';
@@ -833,8 +833,8 @@ export declare namespace GradientAI {
833833
type APIAgreement as APIAgreement,
834834
type APIModel as APIModel,
835835
type APIModelVersion as APIModelVersion,
836-
type Model as Model,
837836
type ModelListResponse as ModelListResponse,
837+
type ModelListParams as ModelListParams,
838838
};
839839

840840
export type APILinks = API.APILinks;

src/resources/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export {
4242
type APIAgreement,
4343
type APIModel,
4444
type APIModelVersion,
45-
type Model,
4645
type ModelListResponse,
46+
type ModelListParams,
4747
} from './models';
4848
export { Regions, type RegionListResponse, type RegionListParams } from './regions';

src/resources/models.ts

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
import { APIResource } from '../core/resource';
4+
import * as Shared from './shared';
45
import { APIPromise } from '../core/api-promise';
56
import { RequestOptions } from '../internal/request-options';
6-
import { path } from '../internal/utils/path';
77

88
export class Models extends APIResource {
99
/**
10-
* Retrieves a model instance, providing basic information about the model such as
11-
* the owner and permissioning.
10+
* To list all models, send a GET request to `/v2/gen-ai/models`.
1211
*/
13-
retrieve(model: string, options?: RequestOptions): APIPromise<Model> {
14-
return this._client.get(path`/models/${model}`, {
15-
defaultBaseURL: 'https://inference.do-ai.run/v1',
12+
list(
13+
query: ModelListParams | null | undefined = {},
14+
options?: RequestOptions,
15+
): APIPromise<ModelListResponse> {
16+
return this._client.get('/v2/gen-ai/models', {
17+
query,
18+
defaultBaseURL: 'https://api.digitalocean.com',
1619
...options,
1720
});
1821
}
19-
20-
/**
21-
* Lists the currently available models, and provides basic information about each
22-
* one such as the owner and availability.
23-
*/
24-
list(options?: RequestOptions): APIPromise<ModelListResponse> {
25-
return this._client.get('/models', { defaultBaseURL: 'https://inference.do-ai.run/v1', ...options });
26-
}
2722
}
2823

2924
export interface APIAgreement {
@@ -66,43 +61,59 @@ export interface APIModelVersion {
6661
patch?: number;
6762
}
6863

69-
/**
70-
* Describes a model offering that can be used with the API.
71-
*/
72-
export interface Model {
64+
export interface ModelListResponse {
65+
links?: Shared.APILinks;
66+
67+
meta?: Shared.APIMeta;
68+
69+
models?: Array<APIModel>;
70+
}
71+
72+
export interface ModelListParams {
7373
/**
74-
* The model identifier, which can be referenced in the API endpoints.
74+
* page number.
7575
*/
76-
id: string;
76+
page?: number;
7777

7878
/**
79-
* The Unix timestamp (in seconds) when the model was created.
79+
* items per page.
8080
*/
81-
created: number;
81+
per_page?: number;
8282

8383
/**
84-
* The object type, which is always "model".
84+
* only include models that are publicly available.
8585
*/
86-
object: 'model';
86+
public_only?: boolean;
8787

8888
/**
89-
* The organization that owns the model.
89+
* include only models defined for the listed usecases.
90+
*
91+
* - MODEL_USECASE_UNKNOWN: The use case of the model is unknown
92+
* - MODEL_USECASE_AGENT: The model maybe used in an agent
93+
* - MODEL_USECASE_FINETUNED: The model maybe used for fine tuning
94+
* - MODEL_USECASE_KNOWLEDGEBASE: The model maybe used for knowledge bases
95+
* (embedding models)
96+
* - MODEL_USECASE_GUARDRAIL: The model maybe used for guardrails
97+
* - MODEL_USECASE_REASONING: The model usecase for reasoning
98+
* - MODEL_USECASE_SERVERLESS: The model usecase for serverless inference
9099
*/
91-
owned_by: string;
92-
}
93-
94-
export interface ModelListResponse {
95-
data: Array<Model>;
96-
97-
object: 'list';
100+
usecases?: Array<
101+
| 'MODEL_USECASE_UNKNOWN'
102+
| 'MODEL_USECASE_AGENT'
103+
| 'MODEL_USECASE_FINETUNED'
104+
| 'MODEL_USECASE_KNOWLEDGEBASE'
105+
| 'MODEL_USECASE_GUARDRAIL'
106+
| 'MODEL_USECASE_REASONING'
107+
| 'MODEL_USECASE_SERVERLESS'
108+
>;
98109
}
99110

100111
export declare namespace Models {
101112
export {
102113
type APIAgreement as APIAgreement,
103114
type APIModel as APIModel,
104115
type APIModelVersion as APIModelVersion,
105-
type Model as Model,
106116
type ModelListResponse as ModelListResponse,
117+
type ModelListParams as ModelListParams,
107118
};
108119
}

tests/api-resources/models.test.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const client = new GradientAI({
1010

1111
describe('resource models', () => {
1212
// skipped: tests are disabled for the time being
13-
test.skip('retrieve', async () => {
14-
const responsePromise = client.models.retrieve('llama3-8b-instruct');
13+
test.skip('list', async () => {
14+
const responsePromise = client.models.list();
1515
const rawResponse = await responsePromise.asResponse();
1616
expect(rawResponse).toBeInstanceOf(Response);
1717
const response = await responsePromise;
@@ -22,14 +22,13 @@ describe('resource models', () => {
2222
});
2323

2424
// skipped: tests are disabled for the time being
25-
test.skip('list', async () => {
26-
const responsePromise = client.models.list();
27-
const rawResponse = await responsePromise.asResponse();
28-
expect(rawResponse).toBeInstanceOf(Response);
29-
const response = await responsePromise;
30-
expect(response).not.toBeInstanceOf(Response);
31-
const dataAndResponse = await responsePromise.withResponse();
32-
expect(dataAndResponse.data).toBe(response);
33-
expect(dataAndResponse.response).toBe(rawResponse);
25+
test.skip('list: request options and params are passed correctly', async () => {
26+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
27+
await expect(
28+
client.models.list(
29+
{ page: 0, per_page: 0, public_only: true, usecases: ['MODEL_USECASE_UNKNOWN'] },
30+
{ path: '/_stainless_unknown_path' },
31+
),
32+
).rejects.toThrow(GradientAI.NotFoundError);
3433
});
3534
});

0 commit comments

Comments
 (0)