-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathsaved-extensions.ts
More file actions
149 lines (135 loc) · 4.16 KB
/
saved-extensions.ts
File metadata and controls
149 lines (135 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import * as Shared from './shared';
import { APIPromise } from '../core/api-promise';
import { buildHeaders } from '../internal/headers';
import { RequestOptions } from '../internal/request-options';
import { path } from '../internal/utils/path';
export class SavedExtensions extends APIResource {
/**
* This API creates a new saved extension. Saved extensions allow you to save
* complex extension configurations (like AI tasks) and reuse them by referencing
* the ID in upload or update file APIs.
*
* **Saved extension limit** \
* You can create a maximum of 100 saved extensions per account.
*
* @example
* ```ts
* const savedExtension = await client.savedExtensions.create({
* config: {
* name: 'ai-tasks',
* tasks: [
* {
* instruction: 'What types of clothing items are visible in this image?',
* type: 'select_tags',
* vocabulary: ['shirt', 'dress', 'pants', 'jacket', 'shoes'],
* max_selections: 3,
* },
* ],
* },
* description: 'Automatically categorizes clothing items in fashion images',
* name: 'Fashion Item Categorization',
* });
* ```
*/
create(body: SavedExtensionCreateParams, options?: RequestOptions): APIPromise<Shared.SavedExtension> {
return this._client.post('/v1/saved-extensions', { body, ...options });
}
/**
* This API updates an existing saved extension. You can update the name,
* description, or config.
*
* @example
* ```ts
* const savedExtension = await client.savedExtensions.update(
* 'id',
* );
* ```
*/
update(
id: string,
body: SavedExtensionUpdateParams,
options?: RequestOptions,
): APIPromise<Shared.SavedExtension> {
return this._client.patch(path`/v1/saved-extensions/${id}`, { body, ...options });
}
/**
* This API returns an array of all saved extensions for your account. Saved
* extensions allow you to save complex extension configurations and reuse them by
* referencing them by ID in upload or update file APIs.
*
* @example
* ```ts
* const savedExtensions = await client.savedExtensions.list();
* ```
*/
list(options?: RequestOptions): APIPromise<SavedExtensionListResponse> {
return this._client.get('/v1/saved-extensions', options);
}
/**
* This API deletes a saved extension permanently.
*
* @example
* ```ts
* await client.savedExtensions.delete('id');
* ```
*/
delete(id: string, options?: RequestOptions): APIPromise<void> {
return this._client.delete(path`/v1/saved-extensions/${id}`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* This API returns details of a specific saved extension by ID.
*
* @example
* ```ts
* const savedExtension = await client.savedExtensions.get(
* 'id',
* );
* ```
*/
get(id: string, options?: RequestOptions): APIPromise<Shared.SavedExtension> {
return this._client.get(path`/v1/saved-extensions/${id}`, options);
}
}
export type SavedExtensionListResponse = Array<Shared.SavedExtension>;
export interface SavedExtensionCreateParams {
/**
* Configuration object for an extension (base extensions only, not saved extension
* references).
*/
config: Shared.ExtensionConfig;
/**
* Description of what the saved extension does.
*/
description: string;
/**
* Name of the saved extension.
*/
name: string;
}
export interface SavedExtensionUpdateParams {
/**
* Configuration object for an extension (base extensions only, not saved extension
* references).
*/
config?: Shared.ExtensionConfig;
/**
* Updated description of the saved extension.
*/
description?: string;
/**
* Updated name of the saved extension.
*/
name?: string;
}
export declare namespace SavedExtensions {
export {
type SavedExtensionListResponse as SavedExtensionListResponse,
type SavedExtensionCreateParams as SavedExtensionCreateParams,
type SavedExtensionUpdateParams as SavedExtensionUpdateParams,
};
}