1
1
package com.aallam.openai.api.message
2
2
3
+ import com.aallam.openai.api.BetaOpenAI
4
+ import com.aallam.openai.api.assistant.AssistantTool
3
5
import com.aallam.openai.api.file.FileId
4
6
import kotlinx.serialization.SerialName
5
7
import kotlinx.serialization.Serializable
@@ -8,9 +10,42 @@ import kotlinx.serialization.Serializable
8
10
* References an Attachment in the message request.
9
11
*/
10
12
@Serializable
13
+ @OptIn(BetaOpenAI ::class )
11
14
public data class Attachment (
12
15
/* *
13
16
* The ID of the file to attach to the message.
14
17
*/
15
- @SerialName(" file_id" ) val fileId : FileId
18
+ @SerialName(" file_id" ) val fileId : FileId ? = null ,
19
+
20
+ /* *
21
+ * The tools to add this file to.
22
+ */
23
+ @SerialName(" tools" ) val tools : List <AssistantTool >? = null ,
16
24
)
25
+
26
+ /* *
27
+ * A message attachment builder.
28
+ */
29
+ public fun attachment (block : AttachmentBuilder .() -> Unit ): Attachment = AttachmentBuilder ().apply (block).build()
30
+
31
+ /* *
32
+ * A message attachment builder.
33
+ */
34
+ public class AttachmentBuilder {
35
+ /* *
36
+ * The ID of the file to attach to the message.
37
+ */
38
+ public var fileId: FileId ? = null
39
+
40
+ /* *
41
+ * The tools to add this file to.
42
+ */
43
+ @OptIn(BetaOpenAI ::class )
44
+ public var tools: List <AssistantTool >? = null
45
+
46
+ /* *
47
+ * Build the attachment.
48
+ */
49
+ @OptIn(BetaOpenAI ::class )
50
+ public fun build (): Attachment = Attachment (fileId, tools)
51
+ }
0 commit comments