1
- import { ContentBlock } from "./index .js" ;
1
+ import { ContentBlock as BaseContentBlock } from "./base .js" ;
2
2
3
3
// eslint-disable-next-line @typescript-eslint/no-namespace
4
- export declare namespace MultimodalContentBlocks {
5
- /** Content block for multimodal data */
6
- export interface DataContentBlock <
7
- TMetadata extends Record < string , unknown > = Record < string , unknown >
8
- > extends ContentBlock {
4
+ export declare namespace Multimodal {
5
+ type DataRecordFileId = {
6
+ /**
7
+ * ID of the image file. e.g. from the OpenAI file api
8
+ */
9
+ fileId : string ;
10
+ url ?: never ;
11
+ data ?: never ;
12
+ } ;
13
+ type DataRecordUrl = {
14
+ fileId ?: never ;
9
15
/**
10
- * MIME type of the file. Required for base64 encoding.
16
+ * URL of the data file
11
17
*/
12
- mimeType ?: string ;
18
+ url : string ;
19
+ data ?: never ;
20
+ } ;
21
+ type DataRecordData = {
22
+ fileId ?: never ;
23
+ url ?: never ;
13
24
/**
14
- * Metadata of the file
25
+ * Base64 encoded string or binary data of the data
15
26
*/
16
- metadata ?: TMetadata ;
17
- }
27
+ data : string | Uint8Array ;
28
+ } ;
29
+ type DataRecord = DataRecordFileId | DataRecordUrl | DataRecordData ;
30
+
31
+ /** Content block for multimodal data */
32
+ export type Data <
33
+ TMetadata extends Record < string , unknown > = Record < string , unknown >
34
+ > = BaseContentBlock &
35
+ DataRecord & {
36
+ /**
37
+ * MIME type of the file. Required for base64 encoding.
38
+ */
39
+ mimeType ?: string ;
40
+ /**
41
+ * Metadata of the file
42
+ */
43
+ metadata ?: TMetadata ;
44
+ /**
45
+ * Content block identifier for multimodal content, e.g. image, video, audio, file or plain text. This can be either:
46
+ * - generated by the provider (e.g., an OpenAI block ID)
47
+ * - generated by LangChain upon creation
48
+ */
49
+ id ?: string ;
50
+ } ;
18
51
19
52
/** Content block for image data */
20
- export interface ImageContentBlock extends DataContentBlock {
53
+ export type Image = Data & {
21
54
/**
22
55
* Type of the content block
23
56
*/
24
57
readonly type : "image" ;
25
- /**
26
- * Image content block identifier, which can be either
27
- * - generated by the provider (e.g., an OpenAI image block ID)
28
- * - generated by LangChain upon creation
29
- */
30
- id ?: string ;
31
- /**
32
- * ID of the image file. e.g. from the OpenAI file api
33
- */
34
- fileId ?: string ;
35
- /**
36
- * MIME type of the image file. Required for base64 encoding.
37
- */
38
- mimeType ?: string ;
39
- /**
40
- * URL of the image file
41
- */
42
- url ?: string ;
43
- /**
44
- * Base64 encoded data of the image file
45
- */
46
- base64 ?: string ;
47
- }
58
+ } ;
48
59
/** Content block for video data */
49
- export interface VideoContentBlock extends DataContentBlock {
60
+ export type Video = Data & {
50
61
/**
51
62
* Type of the content block
52
63
*/
53
64
readonly type : "video" ;
54
- /**
55
- * Video content block identifier, which can be either
56
- * - generated by the provider (e.g., an OpenAI video block ID)
57
- * - generated by LangChain upon creation
58
- */
59
- id ?: string ;
60
- /**
61
- * ID of the video file. e.g. from the OpenAI file api
62
- */
63
- fileId ?: string ;
64
- /**
65
- * MIME type of the video file. Required for base64 encoding.
66
- */
67
- mimeType ?: string ;
68
- /**
69
- * URL of the video file
70
- */
71
- url ?: string ;
72
- /**
73
- * Base64 encoded data of the video file
74
- */
75
- base64 ?: string ;
76
- }
65
+ } ;
77
66
78
67
/** Content block for audio data */
79
- export interface AudioContentBlock extends DataContentBlock {
68
+ export type Audio = Data & {
80
69
/**
81
70
* Type of the content block
82
71
*/
83
72
readonly type : "audio" ;
84
- /**
85
- * Audio content block identifier, which can be either
86
- * - generated by the provider (e.g., an OpenAI audio block ID)
87
- * - generated by LangChain upon creation
88
- */
89
- id ?: string ;
90
- /**
91
- * ID of the audio file. e.g. from the OpenAI file api
92
- */
93
- fileId ?: string ;
94
- /**
95
- * MIME type of the audio file. Required for base64 encoding.
96
- */
97
- mimeType ?: string ;
98
- /**
99
- * URL of the audio file
100
- */
101
- url ?: string ;
102
- /**
103
- * Base64 encoded data of the audio file
104
- */
105
- base64 ?: string ;
106
- }
73
+ } ;
107
74
108
75
/** Content block for plain text data */
109
- export interface PlainTextContentBlock extends DataContentBlock {
76
+ export type PlainText = Data & {
110
77
/**
111
78
* Type of the content block
79
+ * maybe only "text"?
112
80
*/
113
81
readonly type : "text-plain" ;
114
- /**
115
- * Plain text content block identifier, which can be either
116
- * - generated by the provider (e.g., an OpenAI file ID)
117
- * - generated by LangChain upon creation
118
- */
119
- id ?: string ;
120
- /**
121
- * ID of the file. e.g. from the OpenAI file api
122
- */
123
- fileId ?: string ;
124
- /**
125
- * MIME type of the file. Required for base64 encoding.
126
- */
127
- mimeType ?: "text/plain" ;
128
- /**
129
- * URL of the plain text file
130
- */
131
- url ?: string ;
132
- /**
133
- * Base64 encoded data of the file
134
- */
135
- base64 ?: string ;
136
82
/**
137
83
* Plaintext content. This is optional if the data is base64 encoded.
138
84
*/
@@ -145,42 +91,15 @@ export declare namespace MultimodalContentBlocks {
145
91
* Context for the text, e.g. a description or a summary of the text's content
146
92
*/
147
93
context ?: string ;
148
- }
94
+ } ;
149
95
150
96
/** Content block for file data */
151
- export interface FileContentBlock extends DataContentBlock {
97
+ export type File = Data & {
152
98
/**
153
99
* Type of the content block
154
100
*/
155
101
readonly type : "file" ;
156
- /**
157
- * Search call identifier, which can be either
158
- * - generated by the provider (e.g., an OpenAI search call ID)
159
- * - generated by LangChain upon creation
160
- */
161
- id ?: string ;
162
- /**
163
- * ID of the file. e.g. from the OpenAI file api
164
- */
165
- fileId ?: string ;
166
- /**
167
- * MIME type of the file. Required for base64 encoding.
168
- */
169
- mimeType ?: string ;
170
- /**
171
- * URL of the file
172
- */
173
- url ?: string ;
174
- /**
175
- * Base64 encoded data of the file
176
- */
177
- base64 ?: string ;
178
- }
102
+ } ;
179
103
180
- export type Standard =
181
- | ImageContentBlock
182
- | VideoContentBlock
183
- | AudioContentBlock
184
- | PlainTextContentBlock
185
- | FileContentBlock ;
104
+ export type ContentBlock = Image | Video | Audio | PlainText | File ;
186
105
}
0 commit comments