forked from openai/openai-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiles.ts
105 lines (94 loc) · 2.98 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
// File generated from our OpenAPI spec by Stainless.
import * as Core from 'openai/core';
import { APIResource } from 'openai/resource';
import { isRequestOptions } from 'openai/core';
import * as FilesAPI from 'openai/resources/beta/threads/messages/files';
import { CursorPage, type CursorPageParams } from 'openai/pagination';
export class Files extends APIResource {
/**
* Retrieves a message file.
*/
retrieve(
threadId: string,
messageId: string,
fileId: string,
options?: Core.RequestOptions,
): Core.APIPromise<MessageFile> {
return this.get(`/threads/${threadId}/messages/${messageId}/files/${fileId}`, {
...options,
headers: { 'OpenAI-Beta': 'assistants=v1', ...options?.headers },
});
}
/**
* Returns a list of message files.
*/
list(
threadId: string,
messageId: string,
query?: FileListParams,
options?: Core.RequestOptions,
): Core.PagePromise<MessageFilesPage, MessageFile>;
list(
threadId: string,
messageId: string,
options?: Core.RequestOptions,
): Core.PagePromise<MessageFilesPage, MessageFile>;
list(
threadId: string,
messageId: string,
query: FileListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<MessageFilesPage, MessageFile> {
if (isRequestOptions(query)) {
return this.list(threadId, messageId, {}, query);
}
return this.getAPIList(`/threads/${threadId}/messages/${messageId}/files`, MessageFilesPage, {
query,
...options,
headers: { 'OpenAI-Beta': 'assistants=v1', ...options?.headers },
});
}
}
export class MessageFilesPage extends CursorPage<MessageFile> {}
/**
* A list of files attached to a `message`.
*/
export interface MessageFile {
/**
* The identifier, which can be referenced in API endpoints.
*/
id: string;
/**
* The Unix timestamp (in seconds) for when the message file was created.
*/
created_at: number;
/**
* The ID of the [message](https://platform.openai.com/docs/api-reference/messages)
* that the [File](https://platform.openai.com/docs/api-reference/files) is
* attached to.
*/
message_id: string;
/**
* The object type, which is always `thread.message.file`.
*/
object: 'thread.message.file';
}
export interface FileListParams extends CursorPageParams {
/**
* A cursor for use in pagination. `before` is an object ID that defines your place
* in the list. For instance, if you make a list request and receive 100 objects,
* ending with obj_foo, your subsequent call can include before=obj_foo in order to
* fetch the previous page of the list.
*/
before?: string;
/**
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending
* order and `desc` for descending order.
*/
order?: 'asc' | 'desc';
}
export namespace Files {
export import MessageFile = FilesAPI.MessageFile;
export import MessageFilesPage = FilesAPI.MessageFilesPage;
export import FileListParams = FilesAPI.FileListParams;
}