-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathfiles.ts
196 lines (163 loc) · 4.38 KB
/
files.ts
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../resource';
import * as Core from '../core';
export class Files extends APIResource {
/**
* Upload a file that can be used across various endpoints.
*
* The Batch API only supports `.jsonl` files up to 100 MB in size. The input also
* has a specific required [format](/docs/batch).
*
* Please contact us if you need to increase these storage limits.
*/
create(body: FileCreateParams, options?: Core.RequestOptions): Core.APIPromise<FileCreateResponse> {
return this._client.post('/openai/v1/files', Core.multipartFormRequestOptions({ body, ...options }));
}
/**
* Returns a list of files.
*/
list(options?: Core.RequestOptions): Core.APIPromise<FileListResponse> {
return this._client.get('/openai/v1/files', options);
}
/**
* Delete a file.
*/
delete(fileId: string, options?: Core.RequestOptions): Core.APIPromise<FileDeleteResponse> {
return this._client.delete(`/openai/v1/files/${fileId}`, options);
}
/**
* Returns the contents of the specified file.
*/
content(fileId: string, options?: Core.RequestOptions): Core.APIPromise<string> {
return this._client.get(`/openai/v1/files/${fileId}/content`, options);
}
/**
* Returns information about a file.
*/
info(fileId: string, options?: Core.RequestOptions): Core.APIPromise<FileInfoResponse> {
return this._client.get(`/openai/v1/files/${fileId}`, options);
}
}
/**
* The `File` object represents a document that has been uploaded.
*/
export interface FileCreateResponse {
/**
* The file identifier, which can be referenced in the API endpoints.
*/
id?: string;
/**
* The size of the file, in bytes.
*/
bytes?: number;
/**
* The Unix timestamp (in seconds) for when the file was created.
*/
created_at?: number;
/**
* The name of the file.
*/
filename?: string;
/**
* The object type, which is always `file`.
*/
object?: 'file';
/**
* The intended purpose of the file. Supported values are `batch`, and
* `batch_output`.
*/
purpose?: 'batch' | 'batch_output';
}
export interface FileListResponse {
data: Array<FileListResponse.Data>;
object: 'list';
}
export namespace FileListResponse {
/**
* The `File` object represents a document that has been uploaded.
*/
export interface Data {
/**
* The file identifier, which can be referenced in the API endpoints.
*/
id?: string;
/**
* The size of the file, in bytes.
*/
bytes?: number;
/**
* The Unix timestamp (in seconds) for when the file was created.
*/
created_at?: number;
/**
* The name of the file.
*/
filename?: string;
/**
* The object type, which is always `file`.
*/
object?: 'file';
/**
* The intended purpose of the file. Supported values are `batch`, and
* `batch_output`.
*/
purpose?: 'batch' | 'batch_output';
}
}
export interface FileDeleteResponse {
id: string;
deleted: boolean;
object: 'file';
}
export type FileContentResponse = string;
/**
* The `File` object represents a document that has been uploaded.
*/
export interface FileInfoResponse {
/**
* The file identifier, which can be referenced in the API endpoints.
*/
id?: string;
/**
* The size of the file, in bytes.
*/
bytes?: number;
/**
* The Unix timestamp (in seconds) for when the file was created.
*/
created_at?: number;
/**
* The name of the file.
*/
filename?: string;
/**
* The object type, which is always `file`.
*/
object?: 'file';
/**
* The intended purpose of the file. Supported values are `batch`, and
* `batch_output`.
*/
purpose?: 'batch' | 'batch_output';
}
export interface FileCreateParams {
/**
* The File object (not file name) to be uploaded.
*/
file: Core.Uploadable;
/**
* The intended purpose of the uploaded file. Use "batch" for
* [Batch API](/docs/api-reference#batches).
*/
purpose: 'batch';
}
export declare namespace Files {
export {
type FileCreateResponse as FileCreateResponse,
type FileListResponse as FileListResponse,
type FileDeleteResponse as FileDeleteResponse,
type FileContentResponse as FileContentResponse,
type FileInfoResponse as FileInfoResponse,
type FileCreateParams as FileCreateParams,
};
}